如何在没有页面刷新的情况下自动恢复radiobuttonlist? [英] How to autopostback radiobuttonlist without page refresh?

查看:120
本文介绍了如何在没有页面刷新的情况下自动恢复radiobuttonlist?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp.net页面中使用了radiobuttonlist。每当我选择任何列表项时,每次都会刷新页面。如何避免页面刷新?

I have used radiobuttonlist in my asp.net page. Whenever I select any list item, the page refresh every time. How can page refresh be avoided?

推荐答案

1.属性 AutoPostBack 何时设置为 true 将生成页面回发,postabck表示整个页面都发送到Web服务器。



2.The解决方案通知服务器您的radiobuttonlist是更改是在 false 上更改此 AutoPostBack 属性,然后使用Javascript on您的页面将使用AJAX调用您的Web服务器中的代码,这样只会重新呈现页面的部分区域。
1.The property AutoPostBack when is set on true will generate postback of your page, and postabck means that the entire page is send to the web server.

2.The solution to notify the server that your radiobuttonlist was changes is to change this AutoPostBack property on false and then to use Javascript on your page that will invoke by using AJAX your code from your web server and in this way only a partial zone of your page will be re-rendered.


使用updatepanel控件,请尝试以下示例:

1.在aspx页面上:

Use updatepanel control, try the following example:
1. On the aspx page:
<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager" runat="Server" EnablePartialRendering="true" />
<asp:UpdatePanel ID="updatePanel1" runat="server">
    <ContentTemplate>
        Light Switch&nbsp;&nbsp;
        <asp:RadioButton ID="lightOn" AutoPostBack="true" runat="server"

            GroupName="switch" Text="Turn On" OnCheckedChanged="lightOn_CheckedChanged" />
        &nbsp;&nbsp;&nbsp;
        <asp:RadioButton ID="lightOff" AutoPostBack="true" runat="server"

            GroupName="switch" Text="Turn Off" OnCheckedChanged="lightOff_CheckedChanged" />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <br />
        <asp:Label ID="Label1" runat="server"></asp:Label>
    </ContentTemplate>
</asp:UpdatePanel>



2.关于代码:


2. On the code behind:

protected void lightOn_CheckedChanged(object sender, EventArgs e)
{
    Label1.Text = "Light has been turned on";
}
protected void lightOff_CheckedChanged(object sender, EventArgs e)
{
    Label1.Text = "Light has been turned off";
}



了解更多信息简介到UpdatePanel控件 [ ^ ]


use update panel control and put the radio button list control inside the panel

and use a script manager and set the partialRendering property of script manager=true


这篇关于如何在没有页面刷新的情况下自动恢复radiobuttonlist?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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