My page has 2 usercontrols dynamically created. Both implement IPostBackEventHandler. I created the RaisePostBackEvent method. In the parent page, I used GetPostBackEventReference. The first time, it works fine. In the next few clicks need to click 2 times to enter the RaisePostBackEvent. Anyone have any tips? The following code:
Parent Page -
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
-
CarregaUserControl()
-
End Sub
-
-
Private Sub CarregaUserControl()
-
divControls.Controls.Clear()
-
-
Select Case p_Step
-
Case WizardStep.PersonalData
-
uc_usrDadosPessoais = CType(LoadControl("~/UserControl/User.ascx"), UserControl_User)
-
divControls.Controls.Add(uc_usrDadosPessoais)
-
-
'lnkPersonalData.OnClientClick = "LinkClicado(1);" + Page.ClientScript.GetPostBackClientHyperlink(uc_usrDadosPessoais, "GERAREVENTO") + ";"
-
'lnkCategory.OnClientClick = "LinkClicado(2);" + Page.ClientScript.GetPostBackClientHyperlink(uc_usrDadosPessoais, "GERAREVENTO") + ";"
-
lnkPersonalData.Attributes.Add("onclick", "LinkClicado(1);" + Page.ClientScript.GetPostBackEventReference(uc_usrDadosPessoais, "GERAREVENTO") + ";document.forms[0].submit();")
-
lnkCategory.Attributes.Add("onclick", "LinkClicado(2);" + Page.ClientScript.GetPostBackEventReference(uc_usrDadosPessoais, "GERAREVENTO") + ";document.forms[0].submit();")
-
Case WizardStep.Category
-
uc_usrCategorias = CType(LoadControl("~/UserControl/UserCategory.ascx"), UserControl_UserCategory)
-
divControls.Controls.Add(uc_usrCategorias)
-
-
lnkPersonalData.Attributes.Add("onclick", "LinkClicado(1);" + Page.ClientScript.GetPostBackEventReference(uc_usrCategorias, "GERAREVENTO") + ";document.forms[0].submit();")
-
lnkCategory.Attributes.Add("onclick", "LinkClicado(2);" + Page.ClientScript.GetPostBackEventReference(uc_usrCategorias, "GERAREVENTO") + ";document.forms[0].submit();")
-
End Select
-
End Sub
-
-
Private Sub UCEvent(sender As Object, e As System.EventArgs) Handles uc_usrDadosPessoais.UCEvent, uc_usrCategorias.UCEvent
-
p_StepPrevious = p_Step
-
Select Case p_StepPrevious
-
Case WizardStep.PersonalData
-
uc_usrDadosPessoais.SaveData()
-
Case WizardStep.Category
-
uc_usrCategorias.SaveData()
-
End Select
-
-
p_Step = Integer.Parse(hdnLinkClicado.Value)
-
CarregaUserControl()
-
End Sub
UserControl -
Public Event UCEvent As EventHandler
-
Public Overrides Sub RaisePostbackEvent(ByVal eventArgument As String)
-
Try
-
If eventArgument.Equals("GERAREVENTO") Then
-
RaiseEvent UCEvent(Me, New EventArgs())
-
End If
-
Catch ex As Exception
-
-
End Try
-
End Sub