Click here to Skip to main content
15,868,420 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
unable to access controls within a panel from code behind

this is the code in my .aspx page




XML
<div>
  <asp:Panel ID="Panel1" runat="server" CssClass="modalPopup"   Style="display:none; " Width="300px">
  <div  class="inputtext">
    <div style=" margin:20px"><h2>Forgot Password</h2><br />
     <p>To retrieve your password please enter your<br /> email address.</p><br />
      <div align="center">
       <div style="margin-left:-100px">Email:
       </div>
       <div><asp:TextBox ID="TbUnme" runat="server" ValidationGroup="group3">
            </asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
                ErrorMessage="*" ControlToValidate="TbUnme" ValidationGroup="group3">
            </asp:RequiredFieldValidator>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator5" runat="server"
                ErrorMessage="*" 
                ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" 
                ValidationGroup="group3"  ControlToValidate="TbUnme">
            </asp:RegularExpressionValidator>
       </div>
       <div style="margin-left:-50px">Confirm Email:
       </div>
       <div><asp:TextBox ID="TbConEmail"  ValidationGroup="group3" runat="server">
            </asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" 
                ErrorMessage="*" ValidationGroup="group3" ControlToValidate="TbConEmail">
            </asp:RequiredFieldValidator>
            <asp:CompareValidator ID="CompareValidator1" runat="server" 
                ErrorMessage="*" ControlToValidate="TbConEmail" 
                ValidationGroup="group3" ControlToCompare="TbUnme">
            </asp:CompareValidator>
        </div><br />
        <div><asp:Button ID="OkButton" runat="server"  Text="Submit" 
                ValidationGroup="group3" />
        </div><br />
        <div style="text-align:left" class="errortext">
            <asp:Label ID="Labelmsgs"  runat="server">
            </asp:Label>
        </div>
        <div style="text-align:right"> 
            <asp:Label  ID="CancelButton" runat="server" Text="[Close]" >
            </asp:Label>
        </div>
       </div>
     </div>
  </div>
</div>
  </asp:Panel>
   <br />


   <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
             TargetControlID="LbtnForgotpswd"
             PopupControlID="Panel1"
             BackgroundCssClass="modalBackground"
             CancelControlID="CancelButton"
              X="750" Y="300" > </asp:ModalPopupExtender>
   </div>




i am unable to get on click events as well as unable to get the button controls in my codebehind file.

[Modified: just moved the code down a couple of lines so it wouldn't be so squished. Also fixed the formatting.]
Posted
Updated 27-May-10 7:04am
v5
Comments
Dalek Dave 27-May-10 10:13am    
Reason for my vote of 1
Not a question, but a statement.
No context.
No Code.
Bad Grammar!

santoshamrutha wrote:
unable to access controls within a panel from code behind


Neither can I, but then I haven't written any code to even try.

Presumably you have and it would be awfully nice if you would edit your question to include the relevant parts of your code, so that someone might have a clue as to what has gone wrong.
 
Share this answer
 
There is usually a lever that you pull that allows for maintenance of such panels.

Alternatively, you could post what you have actually done and let us have a gander at it!
 
Share this answer
 
v2
I am not certain if this is what you are looking for but,

<asp:button id="OkButton" runat="server" text="Submit" xmlns:asp="#unknown"><br />
                ValidationGroup="group3" /></asp:button>

should contain

onclick="OkButton_Click" within in it

Like so:

<asp:button id="OkButton" runat="server" text="Submit" xmlns:asp="#unknown"><br />
                ValidationGroup="group3" onclick="OkButton_Click" /></asp:button>


Then in your aspx.cs file for the page create a function for OkButton_Click

I hope this helps and again this i just a guess.

Also, if this is in an update panel then you would have to add the button's ID to the triggers for the update panel.
 
Share this answer
 
v2
not sure if this could be your problem, but you close out the div that the panel is in before closing out the panel.

This is where keeping your code properly formatted can help you. Whenever I open an HTML item, I always close it on the next line and then fill in the items in between them. That was I ensure that everything is closed properly.

Try removing one of the <\div> right before you close the panel in the HTML. If that doesn't fix it, then you must have some problems in the code behind, but we can't tell you what without seeing it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900