为什么整个页面都回传和单选失去了它的价值呢? [英] Why does the whole page do postback and RadioButton loses its value?

查看:82
本文介绍了为什么整个页面都回传和单选失去了它的价值呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从一个单选按钮选择运行一个查询来填充一个DropDownList。我不想整个页面做了回发。我的整个页面回发。

此外,当我这个页面复制到一个测试页面,单选按钮的值丢失。我需要的单选按钮来驱动他们查询哪些填充下拉列表。

我是什么做错了,这是造成一个完整的回发?

(该方法 FillAppointmentTypes_SelectedIndexChanged 永远不会执行。)

 < ASP:的ScriptManager ID =ScriptManager1=服务器>
< / ASP:ScriptManager的>
< ASP:的UpdatePanel ID =updatePanelToggle=服务器>  <&的ContentTemplate GT;
    < D​​IV CLASS =表单组>
      <标签=radDoctors级=COL-MD-3控制标签>
        选择你的医生:LT;跨度ID =ASDF>< / SPAN>
      < /标签>
      < D​​IV CLASS =COL-MD-9>
        < ASP:RadioButtonList的ID =radDoctors=服务器的CssClass =
          OnSelectedIndexChanged =FillAppointmentTypes_SelectedIndexChanged
          的AutoPostBack =真>
        < / ASP:RadioButtonList的>
      < / DIV>
    < / DIV>
    < D​​IV CLASS =表单组>
      <标签=ddAppointmentTypes级=COL-MD-3控制标签>
        原因访问:LT;跨度ID =Span1>< / SPAN>
      < /标签>
      < D​​IV CLASS =COL-MD-9>
        < ASP:DropDownList的ID =ddAppointmentTypes=服务器>
        < / ASP:DropDownList的>
      < / DIV>
    < / DIV>
  < /&的ContentTemplate GT;
< / ASP:的UpdatePanel>

我曾尝试updatedatePanel内容模板内部和外部触发器,没有爱情:

 <&触发器GT;
  < ASP:AsyncPostBackTrigger控件ID =radDoctors事件名称=的SelectedIndexChanged/>
< /触发器>


解决方案

把...

 如果(page.ispostback)
{
返回;
}

在你的页面加载事件的顶部。

希望这有助于

另外也许设置ChildAsTrigger =真上的UpdatePanel

I want a selection from a radio button to run a query to populate a DropDownList. I do not want the whole page to do a postback. My whole page is posting back.

Also, when I copy this page to a test page, the value of the radio button is lost. I need the radio button to drive they query which populates the dropdown.

What am I doing wrong which is causing a full postback?

(The method "FillAppointmentTypes_SelectedIndexChanged" is never executed.)

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>


<asp:UpdatePanel ID="updatePanelToggle" runat="server">

  <ContentTemplate>
    <div class="form-group">
      <label for="radDoctors" class="col-md-3 control-label">
        Choose your doctor: <span id="asdf"></span>
      </label>
      <div class="col-md-9">
        <asp:RadioButtonList ID="radDoctors" runat="server" CssClass="" 
          OnSelectedIndexChanged="FillAppointmentTypes_SelectedIndexChanged"
          AutoPostBack="True">
        </asp:RadioButtonList>
      </div>
    </div>
    <div class="form-group">
      <label for="ddAppointmentTypes" class="col-md-3 control-label">
        Reason for Visit: <span id="Span1"></span>
      </label>
      <div class="col-md-9">
        <asp:DropDownList ID="ddAppointmentTypes" runat="server">
        </asp:DropDownList>
      </div>
    </div>
  </ContentTemplate>
</asp:UpdatePanel>

I have tried a trigger inside the updatedatePanel and outside the content template, no love:

<Triggers>
  <asp:AsyncPostBackTrigger ControlID="radDoctors" EventName="SelectedIndexChanged" />
</Triggers>

解决方案

Put...

if(page.ispostback) 
{
return;
}

At the top of your page load event..

Hope this helps

Also maybe set the ChildAsTrigger="true" on the updatepanel

这篇关于为什么整个页面都回传和单选失去了它的价值呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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