Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening new window

Status
Not open for further replies.

Peppi

Programmer
Joined
Apr 9, 2001
Messages
205
Location
CA
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:

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.
 
upon selecting the Preview button subsequent times, the Page_Load event does not get fired
So you are saying that you have a LinkButton that only causes a page to postback the first time that you click it and not on subsequent clicks?


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
Yes, that's what it seems to be doing, as I set a breakpoint on the Page_Load event and it only ever gets executed the first time that I click on the Preview link.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top