Hi,
I have a Preview (LinkButton) on my page. When I click the link, I need to set some session variables. I then need to open a new page in a dialog window (using Javascript's showModalDialog). In the Page_Load event of this new page, the data in the session variables are retrieved and the content is displayed. This works fine the first time, however, upon selecting the Preview button subsequent times, the Page_Load event does not get fired and so the content is not updated.
Here is the relevant code:
How can I get this to work?
Thx.
I have a Preview (LinkButton) on my page. When I click the link, I need to set some session variables. I then need to open a new page in a dialog window (using Javascript's showModalDialog). In the Page_Load event of this new page, the data in the session variables are retrieved and the content is displayed. This works fine the first time, however, upon selecting the Preview button subsequent times, the Page_Load event does not get fired and so the content is not updated.
Here is the relevant code:
Code:
'Event handler for Preview button.
Protected Sub cmdPreview_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdPreview.Click
Dim previewBulletin As String
Session("BulletinData") = reBulletin.Html
Session("BulletinColor") = tbBackground.Text.Trim
previewBulletin = "<script language='javascript'>" & vbCrLf & _
"PreviewBulletin('" & WebUtils.GetServerBaseUrl & "DesktopModules/RiseBulletin/BulletinPreview.aspx', '" & tbWidth.ClientID & "', '" & tbHeight.ClientID & "')" & vbCrLf & "</script>" & vbCrLf
If Not Page.ClientScript.IsStartupScriptRegistered(Me.GetType, "previewBulletin") Then
Page.ClientScript.RegisterStartupScript (Me.GetType, "previewBulletin", previewBulletin)
End If
End Sub
'Page_Load event of new page.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim bulletinData As String = String.Empty
Dim bulletinColor As String = String.Empty
If Not Session("BulletinData") Is Nothing Then
bulletinData = Session("BulletinData").ToString
End If
If Not Session("BulletinColor") Is Nothing Then
bulletinColor = Session("BulletinColor").ToString
End If
bulletin.InnerHtml = bulletinData
bodyElement.Attributes("bgcolor") = bulletinColor
End Sub
'Javascript that opens the new page.
<script language="javaScript" type="text/javascript">
function PreviewBulletin(url, width, height){
var sFeatures= "dialogHeight:" + document.getElementById(height).value + "px;dialogWidth:" + document.getElementById(width).value +"px;" + "scroll:no;status:no"
window.showModelessDialog(url, "", sFeatures);
}
</script>
How can I get this to work?
Thx.