UpdatePanel and panel visibility asp.net c# -
i have 2 panels. each panel contains updatepanel. first panel password textbox.
i set second panel's visibility on page_load false. if user enters correct password, second panel should visible , first panel shouldnd.
the code:
<asp:panel id="passwordpanel" runat="server"> <asp:updatepanel id="updatepanel2" updatemode="conditional" runat="server"> <contenttemplate> geben sie das passwort ein:<br /> <br /> <asp:textbox id="txtpassword" autopostback="false" runat="server" textmode="password"></asp:textbox> <br /> <br /> <asp:button id="btnconfirmpassword" runat="server" autopostback="true" text="senden" cssclass="button" onclick="btnconfirmpassword_click"/> </contenttemplate> </asp:updatepanel> </asp:panel> <asp:panel id="paneluploaddownload" runat="server"> <h2>upload paketformeln csv</h2> <input type="file" id="myfile" name="myfile" /> <asp:button runat="server" id="btnupload" onclick="btnuploadclick" cssclass="button" text="upload" /> <asp:updatepanel id="updatepanel1" updatemode="conditional" runat="server"> <contenttemplate> <br /> <asp:label id="lblstatus" runat="server" text="statuslabel"></asp:label> <br /> <asp:panel id="panelchanges" runat="server" cssclass="pnlcss"> <asp:label id="lblchangesheader" runat="server" font-bold="true" forecolor="black" text="Änderungen"></asp:label> <br /> <asp:label id="lblchanges" runat="server" forecolor="#009900" text="changes"></asp:label> <br /> <br /> <asp:button id="btnconfirm" runat="server" onclick="btnconfirm_click" cssclass="button" text="Änderungen bestätigen" /> </asp:panel> </contenttemplate> </asp:updatepanel> <br /> <br /> <br /> <br /> <h2>download paketformeln csv</h2> <p><asp:button id="btndownloadcsv" runat="server" onclick="btndownloadcsv_click" text="download csv" cssclass="button"/></p> </asp:panel>
and c# code:
protected void btnconfirmpassword_click(object sender, eventargs e) { if (txtpassword.text == "xx") { uploaddownloadpanel.visible = true; passwordpanel.visible = false; } }
load event
protected void page_load(object sender, eventargs e) { maincontroller = new maincontroller(); setstatus("", color.black); lblchanges.visible = false; lblchangesheader.visible = false; btnconfirm.visible = false; panelchanges.visible = false; paneluploaddownload.visible = false; }
for reason doesnt work. clues? triggers?
the securestring class doesn't allow see value; that's whole point of it. if want able work value entered passwordbox, use password member of passwordbox instead of securepassword member:
protected void btnconfirmpassword_click(object sender, eventargs e) { if (txtpassword.password == "xx") { uploaddownloadpanel.visible = true; passwordpanel.visible = false; } }
Comments
Post a Comment