Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 自动回发在ASP.NET中第一次不起作用?_C#_Asp.net_Asp.net Ajax - Fatal编程技术网

C# 自动回发在ASP.NET中第一次不起作用?

C# 自动回发在ASP.NET中第一次不起作用?,c#,asp.net,asp.net-ajax,C#,Asp.net,Asp.net Ajax,我在“更新”面板中使用了5个单选按钮,但当我第一次选中单选按钮时,它就不会被选中。在那之后意味着第二次检查它的工作正常,所以请告诉我应该是什么问题。 这是我的密码 <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:RadioButton ID="rbtn_A" runat="server" GroupName="rbt" A

我在“更新”面板中使用了5个单选按钮,但当我第一次选中单选按钮时,它就不会被选中。在那之后意味着第二次检查它的工作正常,所以请告诉我应该是什么问题。 这是我的密码

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
   <ContentTemplate>
       <asp:RadioButton ID="rbtn_A" runat="server" GroupName="rbt" 
            AutoPostBack="true" OnCheckedChanged="rbtn_A_CheckedChanged" />
       <asp:RadioButton ID="rbtn_B" runat="server" GroupName="rbt" AutoPostBack="true"
            OnCheckedChanged="rbtn_B_CheckedChanged" />
       <asp:RadioButton ID="rbtn_C" runat="server" GroupName="rbt" AutoPostBack="true" 
            OnCheckedChanged="rbtn_C_CheckedChanged" />
       <asp:RadioButton ID="rbtn_D" runat="server" GroupName="rbt" AutoPostBack="true" 
            OnCheckedChanged="rbtn_D_CheckedChanged" />
   </ContentTemplate>

默认情况下,在页面加载时,需要选中其中一个单选按钮
true

<asp:RadioButton ID="rbtn_A" runat="server" AutoPostBack="True" GroupName="rbt"
OnCheckedChanged="rbtn_A_CheckedChanged" Checked="True" />

将所有单选按钮设置为
Checked=False可能会对您有所帮助

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
 <ContentTemplate>
   <asp:RadioButton ID="rbtn_A" runat="server" GroupName="rbt" 
        AutoPostBack="true" OnCheckedChanged="rbtn_A_CheckedChanged" Checked="False" />
   <asp:RadioButton ID="rbtn_B" runat="server" GroupName="rbt" AutoPostBack="true"
        OnCheckedChanged="rbtn_B_CheckedChanged" Checked="False"/>
   <asp:RadioButton ID="rbtn_C" runat="server" GroupName="rbt" AutoPostBack="true" 
        OnCheckedChanged="rbtn_C_CheckedChanged" Checked="False"/>
   <asp:RadioButton ID="rbtn_D" runat="server" GroupName="rbt" AutoPostBack="true" 
        OnCheckedChanged="rbtn_D_CheckedChanged" Checked="False"/>
 </ContentTemplate>

我知道这是一篇老文章,但希望这能帮助其他人

对我来说,这不是发生在页面上的事情,而是我如何进入页面

我使用
Server.Transfer(“~/MyPage.aspx”)导航到该页面


更改为
Response.Redirect(“~/MyPage.aspx”)解决了我的问题。

但随后,一切都正常了?我正在网格视图中使用这些单选按钮。但是第一次遇到问题。我检查了所有内容,但不明白问题出在哪里。请显示您的rbtn\u A\u CheckChanged函数您是否在已检查的已更改事件上放置了断点,并查看它是否触发?许多可能会影响您的代码。您是否根据我的功能检查了客户端函数(如果您有),我不能这样做,因为它与在线检查相关,我需要全部检查错误。如果我第一次检查任何单选按钮,它在“已检查已更改事件”上的“未运行断点”。但是,第二次检查时,它的工作状态良好。请检查网格视图中的单选按钮。它与rbtn_A无关。用户可以第一次检查任何单选按钮。rbtn_A、B、C、D。因为第一次不是在任何已检查的已更改事件上运行断点,而是在第二次运行感谢您对我的帮助
if(!Page.IsPostback)
{
  rbtn_A.Checked = true;
}
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
 <ContentTemplate>
   <asp:RadioButton ID="rbtn_A" runat="server" GroupName="rbt" 
        AutoPostBack="true" OnCheckedChanged="rbtn_A_CheckedChanged" Checked="False" />
   <asp:RadioButton ID="rbtn_B" runat="server" GroupName="rbt" AutoPostBack="true"
        OnCheckedChanged="rbtn_B_CheckedChanged" Checked="False"/>
   <asp:RadioButton ID="rbtn_C" runat="server" GroupName="rbt" AutoPostBack="true" 
        OnCheckedChanged="rbtn_C_CheckedChanged" Checked="False"/>
   <asp:RadioButton ID="rbtn_D" runat="server" GroupName="rbt" AutoPostBack="true" 
        OnCheckedChanged="rbtn_D_CheckedChanged" Checked="False"/>
 </ContentTemplate>