后面的代码和面板 [英] code behind and panel

查看:77
本文介绍了后面的代码和面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无法从后面的代码访问面板中的控件

这是我的.aspx页面中的代码




unable to access controls within a panel from code behind

this is the code in my .aspx page




<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.]

推荐答案

santoshamrutha写道:
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.


那里通常是拉动的杠杆,用于维护此类面板.

另外,您可以发布您实际完成的工作,然后让我们看看它!
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!


我不确定这是否是您想要的,但是,

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>


应该包含

其中的onclick="OkButton_Click"

像这样:


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>



然后在页面的aspx.cs文件中为OkButton_Click
创建一个函数
我希望这会有所帮助,这又是我的猜测.

另外,如果它在更新面板中,则必须将按钮的ID添加到更新面板的触发器中.



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.


这篇关于后面的代码和面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆