countrymeister
asked on
How to invoke a Master page button click from a child page
I need to invoke a master page button click from a child page.
I tried tthe following which does not work. I see the alert pop up but the btnInvalidSession is not triggered
CHILD PAGE
If Session(":LoginID:") Is Nothing Then
Dim btnInvalid As Button = CType(Page.Master.FindCont rol("btnIn validSessi on"), Button)
Dim val As String = btnInvalid.ClientID
Dim msgDesc As String = "if (alert('Your session is no longer valid.\n\n Please login again.')) document.getElementById('" & val & "').click();"
ScriptManager.RegisterClie ntScriptBl ock(Me.Mas ter, Me.Master.GetType(), "Invalid Session", msgDesc, True)
Exit Sub
End If
MASTER PAGE - ASPX
<asp:Button ID="btnInvalidSession" runat="server" style="display:none;" OnClick="InvalidSessionBut ton_Click" />
MASTER PAGE - code behind
Protected Sub InvalidSessionButton_Click (ByVal sender As Object, ByVal e As System.EventArgs) Handles btnInvalidSession.Click
Try
Response.Redirect("login.a spx")
Catch ex As Exception
ex.ToString()
End Try
End Sub
I tried tthe following which does not work. I see the alert pop up but the btnInvalidSession is not triggered
CHILD PAGE
If Session(":LoginID:") Is Nothing Then
Dim btnInvalid As Button = CType(Page.Master.FindCont
Dim val As String = btnInvalid.ClientID
Dim msgDesc As String = "if (alert('Your session is no longer valid.\n\n Please login again.')) document.getElementById('"
ScriptManager.RegisterClie
Exit Sub
End If
MASTER PAGE - ASPX
<asp:Button ID="btnInvalidSession" runat="server" style="display:none;" OnClick="InvalidSessionBut
MASTER PAGE - code behind
Protected Sub InvalidSessionButton_Click
Try
Response.Redirect("login.a
Catch ex As Exception
ex.ToString()
End Try
End Sub
CHILD PAGE
If Session(":LoginID:") Is Nothing Then
Dim btnInvalid As Button = CType(Page.Master.FindControl("btnInvalidSession"), Button)
Dim val As String = btnInvalid.ClientID
Dim msgDesc As String = "if (alert('Your session is no longer valid.\n\n Please login again.')) document.getElementById('" & val & "').click();"
ScriptManager.RegisterClientScriptBlock(Me.Master, Me.Master.GetType(), "Invalid Session", msgDesc, True)
Exit Sub
End If
MASTER PAGE - ASPX
<asp:Button ID="btnInvalidSession" runat="server" style="display:none;" OnClick="InvalidSessionButton_Click" />
MASTER PAGE - code behind
Protected Sub InvalidSessionButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnInvalidSession.Click
Try
Response.Redirect("login.aspx")
Catch ex As Exception
ex.ToString()
End Try
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.