Hi guys, this is my first post here so nice to meet you all.
I'm new working with ASP.NET and AJAX as well, so i will try to explain myself as best as i can. I have created a Web Form from a Master Page, wich has a button that calls a function to show the ModalPopupExtender in which i have two buttons and it works fine, but what i need now is to 'capture' the pressed button and then pass the value to the original form. I can capture the pressed button, but the Web Form won't update and it doesn't shows the value. I have to click on the button that calls the ModalPopupExtender again and then it shows tha value from the last pressed button, but i need to have it before that.
Firstly, this is where i make the Modal in the MasterPage:
<asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate><asp:Panel ID="pnlMensaje" runat="server" CssClass="CajaDialogo" style= "display: none;"><asp:Panel ID="mensajeheaderPanel" runat="server"><table id="mensajetable" width="430px" style="margin: 0px; padding: 0px; height:auto;"><tr><td align="left" valign="middle"><asp:Label ID="headerLabel" runat="server" Text="Message Information" Font-Bold="true"/></td><td valign="middle" align="right"><asp:ImageButton ID="cerrarmensajeImageButton" runat="server" ImageUrl="~/App_Themes/Popup/img/dialog_close.gif" Width="14px" ToolTip="Cerrar mensaje" /></td></tr></table></asp:Panel><table align="left" style="margin: 0px 0px 0px 0px;"><tr><td><asp:Label ID="mensajeLabel" runat="server" Font-Size="13px" Text="Datos de usuario incorrectos" /></td></tr></table><br /><br /><br /><br /><br /><br /><table id="Table1" width="100%"><tr><td align= "center"><asp:HiddenField ID="valBtnOk" runat="server" /><asp:Button ID="btnOk" runat="server" Text="Save" Width="109px" /></td><td align= "center" abbr=" "><asp:HiddenField ID="valBtnCancel" runat="server" /><asp:Button ID="btnCancelar" runat="server" Text="Cancel" Width="109px" ToolTip="Cerrar mensaje" /></td></tr></table></asp:Panel><asp:ModalPopupExtender ID="mpeMensaje" runat="server"
BackgroundCssClass="FondoAplicacion" OkControlID="cerrarmensajeImageButton"
PopupControlID="pnlMensaje" TargetControlID="lblOculto"></asp:ModalPopupExtender><asp:Label ID="lblOculto" runat="server" Text="Label" Style="display: none;"> </asp:Label></ContentTemplate></asp:UpdatePanel>Then comes the function to show the Popup:
Public Sub ShowPopUp(ByVal m As String, ByVal type As Integer, Optional ByVal h As String = "Message Information")
Select Case type
Case 2
pnlmns = "CajaDialogoAdvertencia"
pnlheader = "MensajeHeaderAdvertencia"
lblOK = "OK"
botones = False
Case 1
pnlmns = "CajaDialogoCorrecto"
pnlheader = "MensajeHeaderCorrecto"
lblOK = "Save"
botones = True
Case 0
pnlmns = "CajaDialogoError"
pnlheader = "MensajeHeaderError"
lblOK = "OK"
botones = False
End Select
mpeMensaje.Show()
msn = m
hdr = h
End SubThis only assigns the css styles selected for each button and the message to show. I do all this with WriteOnly propertys like:
WriteOnly Property pnlmns() As String
Set(ByVal value As String)
pnlMensaje.CssClass = value
End Set
End PropertyThe buttons code is like this:
Protected Sub btnOk_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnOk.Click
valBtnOk.Value = 1
valBtnCancel.Value = 0
End SubWhere valBtnOk and valBtnCancel are Hidden Fields to 'capture' the pressed button.
And finally, i call this method from my WebForm in the button click method:
Protected Sub btnSuccess_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSuccess.Click
m.ShowPopUp("Error Message", 1, "Success!")
If m.resBtnCancel = "1" Then
lblRes.Text = "Cancel"
ElseIf m.resBtnOk = "1" Then
lblRes.Text = "OK"
End If
End SubThe problem is, it doesn't 'wait' for the popup to make a desicion before entering the 'If', thus is doesn't get the value until the next click. By the way, the values from the buttons i get them with a ReadOnly property with this code:
ReadOnly Property resBtnOk
Get
Return valBtnOk.Value
End Get
End PropertyI have tried the Javascript method of adding:
function fnClickOK(sender, e) {
__doPostBack(sender, e);
}and then on the load method put this:
btnOk.OnClientClick = [String].Format("fnClickOK('{0}','{1}')", btnOk.UniqueID, "")but that only 'reloads' the Master Page, not the original form.
This is the final step i need to get this working, so if anyone can help me i would really aprecciatte it. Thanks in advance