<bdo id='ZpfzK'></bdo><ul id='ZpfzK'></ul>
    <i id='ZpfzK'><tr id='ZpfzK'><dt id='ZpfzK'><q id='ZpfzK'><span id='ZpfzK'><b id='ZpfzK'><form id='ZpfzK'><ins id='ZpfzK'></ins><ul id='ZpfzK'></ul><sub id='ZpfzK'></sub></form><legend id='ZpfzK'></legend><bdo id='ZpfzK'><pre id='ZpfzK'><center id='ZpfzK'></center></pre></bdo></b><th id='ZpfzK'></th></span></q></dt></tr></i><div id='ZpfzK'><tfoot id='ZpfzK'></tfoot><dl id='ZpfzK'><fieldset id='ZpfzK'></fieldset></dl></div>

  1. <tfoot id='ZpfzK'></tfoot>
      <legend id='ZpfzK'><style id='ZpfzK'><dir id='ZpfzK'><q id='ZpfzK'></q></dir></style></legend>

      <small id='ZpfzK'></small><noframes id='ZpfzK'>

    1. 在回发时保留单选/复选框值?

      时间:2023-06-09
        <bdo id='1918r'></bdo><ul id='1918r'></ul>
      • <legend id='1918r'><style id='1918r'><dir id='1918r'><q id='1918r'></q></dir></style></legend>

            <tbody id='1918r'></tbody>
          1. <i id='1918r'><tr id='1918r'><dt id='1918r'><q id='1918r'><span id='1918r'><b id='1918r'><form id='1918r'><ins id='1918r'></ins><ul id='1918r'></ul><sub id='1918r'></sub></form><legend id='1918r'></legend><bdo id='1918r'><pre id='1918r'><center id='1918r'></center></pre></bdo></b><th id='1918r'></th></span></q></dt></tr></i><div id='1918r'><tfoot id='1918r'></tfoot><dl id='1918r'><fieldset id='1918r'></fieldset></dl></div>

            • <small id='1918r'></small><noframes id='1918r'>

              <tfoot id='1918r'></tfoot>

                本文介绍了在回发时保留单选/复选框值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                ASP 对象有一些我没有得到的东西.我在更新面板中有一个按钮.在同一页面上,我有一个复选框、一个单选按钮和一个文本框(在更新面板之外).当我点击我的按钮时,我可以访问所有这三个对象.文本框能够保留他的文本值.但是当我检查检查状态时,单选/复选框总是返回 false.

                There's is something I don't get with ASP objects. I have a button in a update panel. On the same page, I have a checkbox, a radiobutton and a textbox (outside the update panel). When I click on my button, I access all those three objects. The textbox is able to keep the his text value. But the radio/checkbox always return false when I check there checked state.

                当然,我的表格比我刚才说的要复杂.它涉及 Javascript 和用户控件.我设法使用 Request.Form 来获取我的复选框/收音机的值,但我觉得这个解决方案不够简洁.

                Of course, my form is more complicated than what I just said. It involves Javascript and usercontrols. I managed to use the Request.Form to get the value of my checkbox/radio, but I don't find this solution to be neat enought.

                有人可以帮我找出为什么收音机/支票不会返回真正的支票状态吗?提前谢谢!

                Someone can help me to find why radio/check wont return there real checked state ? Thank you in advance!

                我尝试在一个简单的 aspx 页面中进行跟踪,它似乎有效:

                Edit : I've tried to following in a simple aspx page and it seems to works :

                 <asp:CheckBox runat="server" ID="checkbox" />
                
                    <asp:RadioButton runat="server" ID="radio1" GroupName="radio" CssClass="testRadio" />
                    <asp:RadioButton runat="server" ID="radio2" GroupName="radio" CssClass="testRadio" />
                
                    <asp:TextBox runat="server" ID="text" />
                
                
                    <asp:ScriptManager runat="server">
                    </asp:ScriptManager>
                
                    <asp:UpdatePanel runat="server">
                        <ContentTemplate>
                            <asp:Button runat="server" ID="test_but" OnClick="test_click" />
                
                        </ContentTemplate>
                    </asp:UpdatePanel>
                

                然后我可以访问 test_click() 中的所有属性.所以在我的真实形态中有些东西打破了其他一切.我尝试在我的测试页面中添加一些 javascript,它似乎也可以工作.

                And then I can access all the properties into test_click(). So there is something in my real forms that breaks everything else. I've tried to add a little javascript into my test page, and it seems to works too.

                推荐答案

                这些控件的已知问题.使用 SaveViewState 和 LoadViewState 方法来存储和检索这些值.

                Known issue with these controls. Use the SaveViewState and LoadViewState methods to store and retrieve these values.

                http://www.4guysfromrolla.com/articles/110205-1.aspx

                protected override void LoadViewState(object savedState)
                {
                    base.LoadViewState(savedState);
                
                    if (ViewState["Checked"] != null)
                        checked = (bool)ViewState["Checked"];
                }
                
                protected override object SaveViewState()
                {
                    ViewState["Checked"] = checked;
                
                    return base.SaveViewState();
                }
                

                这篇关于在回发时保留单选/复选框值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何在 C# 应用程序的文本框中执行 VBScript 命令? 下一篇:如何使用 C# 中的 KeyDown 事件使 TextBox 仅接收数字键值?

                相关文章

                <tfoot id='hKu4j'></tfoot>

                    <i id='hKu4j'><tr id='hKu4j'><dt id='hKu4j'><q id='hKu4j'><span id='hKu4j'><b id='hKu4j'><form id='hKu4j'><ins id='hKu4j'></ins><ul id='hKu4j'></ul><sub id='hKu4j'></sub></form><legend id='hKu4j'></legend><bdo id='hKu4j'><pre id='hKu4j'><center id='hKu4j'></center></pre></bdo></b><th id='hKu4j'></th></span></q></dt></tr></i><div id='hKu4j'><tfoot id='hKu4j'></tfoot><dl id='hKu4j'><fieldset id='hKu4j'></fieldset></dl></div>

                    <small id='hKu4j'></small><noframes id='hKu4j'>

                    • <bdo id='hKu4j'></bdo><ul id='hKu4j'></ul>
                    <legend id='hKu4j'><style id='hKu4j'><dir id='hKu4j'><q id='hKu4j'></q></dir></style></legend>