单选按钮停止转换后的工作从ASP.NET 1.1〜3.5 ASP.Net [英] Radio button stopped working after conversion from ASP.NET 1.1 to ASP.Net 3.5

查看:162
本文介绍了单选按钮停止转换后的工作从ASP.NET 1.1〜3.5 ASP.Net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[我张贴我们的问题和解决方案,下面为一个供参考。如果你从微软或一份官方声明中对这个问题进行重新presentative组织,我将标志着,作为一个答案。否则,下面我的职务将作为答案。

[I'm posting our problem and solution below as an FYI. If you have an official statement from Microsoft or a representative organization about this issue, I'll mark that as an answer. Otherwise, my post below will serve as the answer].

我们采取了ASP.Net 1.1程序,并将其转换为ASP.Net 3.5。页面最初默认选中一个单选按钮和项目列表(列表A)显示正确。当我们点击其他的单选按钮,它会显示正确清单B。当我们点击最初选定的单选按钮,第一个列表,列表A,也不会重新显示。单选按钮RadioButtonList控件的一部分。

We took a ASP.Net 1.1 program and converted it to ASP.Net 3.5. The page initially displays correctly with one radio button selected by default and a list of items ("List A"). When we clicked the other radio button, it then displayed List B correctly. When we clicked the originally selected radio button, the first list, List A, would not redisplay. The radio buttons are part of a RadioButtonList control.

我们做了调试:这是驻留在公司内部网上的程序。由于它是NET 1.1,该方案在很大程度上瞄准往Internet Explorer中 - 的JavaScript没有在其他浏览器上运行。 F12开发工具带来了Internet Explorer中的JavaScript调试控制台。附加到IIS 7.5进程(W3wp.exe)与Visual Studio允许我们查看C#服务器code错误。

What we did to debug: This is for a program which resides on a company intranet. Due to it being .Net 1.1, the program is heavily targeted towards Internet Explorer - the JavaScript doesn't run on other browsers. F12 developer tools brings up the JavaScript debugging console in Internet Explorer. Attaching to the IIS 7.5 process (w3wp.exe) with Visual Studio allowed us to view C# server code errors.

我们发现什么:的AutoPostBack被设置为true在RadioButtonList,这其中包含有单选按钮列表项。因此ASP.Net + C#动态生成的单选按钮的的onclick事件doPostBack功能。但是:默认选定的单选按钮正在生成的onclick没有doPostBack功能。我相信这是在ASP.Net 3.5框架和错误RadioButtonList控件。

What we found: AutoPostBack was set to true on the RadioButtonList, which contained the List items which were radio buttons. As a result ASP.Net + C# dynamically generates the doPostBack function in the "onclick" event of the radio button. HOWEVER: no doPostBack function for the onclick was being generated for the default selected radio button. I believe this is a bug in the ASP.Net 3.5 framework and the RadioButtonList control.

编辑:去除问题,并发布解决方案,回答问题,避免关闭。感谢@乔恩P代表的单挑。

edit: Removing solution from question and posting as answer to avoid question closing. Thanks @Jon P for the heads-up.

推荐答案

[我张贴我们的问题和解决方案在这一战后初期作为一个供参考。如果你从微软或一份官方声明中对这个问题进行重新presentative组织,我将标志着,作为一个答案。否则,此信息将作为答案。

1)我们设定的AutoPostBack为false RadioButtonList控件。


2)在该页面的preRender事件中,我们手动将新doPostBack功能,通过在单选按钮列表列表项循环添加到单选按钮列表中的每个列表项。


3)code如下:

1) We set AutoPostBack to false for the RadioButtonList control.

2) In the PreRender event for the page, we manually add the new doPostBack function to each List item in the radio button list by looping through the list items in the RadioButtonList.

3) The code is as follows:

for (int i = 0; i < rbList.Items.Count; i++)
{
    rbList.Items[i].Attributes.Add("onclick", "javascript:setTimeout('__doPostBack(\\'rbList$" + i + "\\',\\'\\')', 0)");
}

4)在onclick事件函数调用code什么ASP.Net 3.5 + C#自动生成结构相匹配。

4) The code in the onclick event function call matches the structure of what ASP.Net 3.5 + C# automatically generate.

此修复程序后,无论是单选按钮必须的onclick事件函数和原始功能得到恢复。

After this fix, both radio buttons had onclick events functions and original functionality was restored.

这篇关于单选按钮停止转换后的工作从ASP.NET 1.1〜3.5 ASP.Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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