asp.net - Update paneel blocks execution of some error messages -


i ave asp page 1 update panels 2 panels controlled 2 buttons if click in first button first panel appears , second becomes hidden , if click second button same thing happens second panel. it's working ok , no problem that.

the problem begins in second panel have update panel in charge of printing error messages. messages check length of input working ok, messages involve querying database check validity of id not being printed .

i thought querying problem , i've tried them in separated page without update panels , working ok. problem lays somewhere update panels. , can't understand where. grateful if can me.

this front end code(i omit insignificant details):

<asp:button id="button1" runat="server" text="[input id?]"  /> <asp:button id="button2" runat="server" text="[aditional info]"  />   .....  <asp:updatepanel id="updatepanel1" runat="server">   <contenttemplate>  < asp:panel id="panel1" runat="server">  code here   </asp:panel>   <asp:panel id="panel2" runat="server">  <b>*id number:&nbsp;&nbsp;</b>  <asp:textbox id="idno" runat="server" ></asp:textbox><font size='2'>   <asp:regularexpressionvalidator id="regularexpressionvalidator1" class="errormess" errormessage="letters not allowed!!" controltovalidate="idnumb" validationexpression="\d+"     runat="server" />     <asp:updatepanel id="updatepanel3" runat="server">    <contenttemplate>    <asp:label id="errorem"  class="errormess" runat="server" text="please fill in required fields"></asp:label>    <asp:label id="errorlenght"  class="errormess" runat="server" text="id long!!!"></asp:label>    <asp:label id="erroruser"  class="errormess" runat="server" text="id not valid!!!"></asp:label>    </contenttemplate>    <triggers>    <asp:asyncpostbacktrigger controlid="button5" eventname="click" />    </triggers>    </asp:updatepanel>     <asp:button id="button5" runat="server" text="generate" /></td></tr>     </asp:panel>     </contenttemplate>     <triggers>    <asp:asyncpostbacktrigger controlid="button1" eventname="click" />    </triggers>    </asp:updatepanel> 

and backend vb code:

 protected sub button5_click(byval sender object, byval e eventargs) handles  button5.click if idno.text = ""     panel1.visible = false     panel2.visible = true     errorem.visible = true elseif idno.text.length > 9     panel1.visible = false     panel2.visible = true     errorlenght.visible = true else      try 'everything comes here not work'         myconn.open()         dim stquery string = "select * account user_id= @id"         dim smd = new mysqlcommand(stquery, myconn)         smd.parameters.addwithvalue("@id", convert.toint32(idno.text))         dim myreader = smd.executereader()         if not myreader.hasrows             panel1.visible = false             panel2.visible = true             erroruser.visible = true             myconn.close()             return         else              panel1.visible = false             panel2.visible = true             myreader.read()             dim errormessage string = "alert('user has been found');"             page.clientscript.registerstartupscript(me.gettype(), "erroralert", errormessage, true)               myconn.close()         end if         myconn.close()     catch ex exception         dim errormessage string = "alert('" & ex.message.tostring() & "');"         page.clientscript.registerstartupscript(me.gettype(), "erroralert", errormessage, true)         myconn.close()     end try end if end sub 

when want execute script inside of update panel - don't use

page.clientscript.registerstartupscript 

use

clientscriptmanager.registerstartupscript 

instead.

ref: http://msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.registerstartupscript.aspx


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -