从.NET 3.5迁移到4.5后出现问题 [英] Issue after migrating from .NET 3.5 to 4.5

查看:165
本文介绍了从.NET 3.5迁移到4.5后出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的代码:



 <   td    >  <   input    类型  =  text    id   =  TextBox_DOSTo                                     < span class =code-attribute>                                                      < span class =code-attribute>                                                      < span class =code-attribute>                                                      < span class =code-attribute>                           runat   =  server  /  >  
< < span class =code-leadattribute> td > < img id = img2 src = Images / calender_grey.gif

< span class =code-attribute> onclick = return myaction('TextBox_DOSTo'); / >
< / td >

function myaction(id){
var el = document.getElementById(id);
// action
}





myaction是java脚本中的一个函数。从3.5迁移到4.5后,服务器标签以id为前缀。所以myaction方法失败了,因为我正在传递文本框id。



我在web.config中有设置但它不能工作:

< pages controlrenderingcompatibilityversion =3.5clientidmode =AutoID > ;.



什么是最好的方法,以便这个功能起作用。我喜欢为此提供全球解决方案。因为我在很多地方都有这种代码。



谢谢

Dhanil



我尝试过:



我尝试将clientIDMode更改为static。但是我不会在其他有冲突的地方工作。

解决方案

检查一下:

ASP.NET Web服务器控件标识





你试过这个吗?

< img id =   img2 src =   Images / calender_grey.gif onclick =   return myaction('<%#Eval(  txtNoRequest%>  ' ); />  


I had a code like this:

<td >                                                                                                                <input type="text" id="TextBox_DOSTo"                                                                                                                runat="server"/>                                                                                                            
                                                                                                            <td>                                                                                                              <img id="img2" src="Images/calender_grey.gif"

onclick="return myaction('TextBox_DOSTo');"  />
                                                                                                            </td>

function myaction(id) {
    var el = document.getElementById(id);
//action
}



myaction is a function in java script. After migrating from 3.5 to 4.5 the server tags are prefixed to the id. So the myaction method fails as it is expecting the text box id as I am passing it.

I have the setting in web.config but it wont work:
<pages controlrenderingcompatibilityversion="3.5" clientidmode="AutoID">.

What can be the best way, so that this function will work. I woluld like to have a global solution for this. Because this kind of code I have in many places.

Thank you
Dhanil

What I have tried:

I tried by changing clientIDMode to static. But i will not work for other places with conflicting ids.

解决方案

Check this:
ASP.NET Web Server Control Identification


Did you try this?

<img id="img2" src="Images/calender_grey.gif" onclick="return myaction('" <%# Eval("txtNoRequest") %> '");"  />


这篇关于从.NET 3.5迁移到4.5后出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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