Click here to Skip to main content
15,907,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I had a code like this:

ASP.NET
<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.
Posted
Updated 1-Dec-16 8:13am
v3
Comments
Cristina Carrasco Angulo 1-Dec-16 14:11pm    
Did you try:
<%# Eval("TextBox_DOSTo") %>
danilmanuel 1-Dec-16 23:46pm    
This cannot be a global solution
Cristina Carrasco Angulo 2-Dec-16 12:04pm    
Ok, why don't you try with jquery?

1 solution

Check this:
ASP.NET Web Server Control Identification


Did you try this?
C#
<img id="img2" src="Images/calender_grey.gif" onclick="return myaction('" <%# Eval("txtNoRequest") %> '");"  />
 
Share this answer
 
v3
Comments
danilmanuel 16-Dec-16 4:49am    
This cannot be a generic solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900