Click here to Skip to main content
15,868,087 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello.
I created an ajax user control, it works prefectly, Used it in a webpage. Now can you help me please how to access my ajax server control properties using javascript in the webpage? [I can modify properties using my control tag].
C#
<cc1:myControl ID="control1"  runat="server" caption="Test" isEditable="true" >
        </cc1:myControl>

Now how can i change values with javascript. I tried this before, but nothing happend.
JavaScript
var c= $find("<%=control1.ClientID%>");
alert(c.get_caption());


I even tried to make an usercontrol, but there is same problem, i cant access properties using javascript.

Thank you!
Posted
Updated 1-Apr-15 1:13am
v2
Comments
ZurdoDev 1-Apr-15 10:25am    
You can't. You can only modify the properties that get generated into the html since that is all JS has access to.
ali_heidari_ 1-Apr-15 11:52am    
I read something about $get(),$find(),$create(). But did not work. also somewhere mention these are not compatible with all browsers, So yeah, I guess you are right, it is not efficient way.
ZurdoDev 1-Apr-15 12:06pm    
$.get() was Microsoft's way of doing what jQuery does before jQuery was around. It was the same as document.getElementById but was still all JavaScript.

1 solution

As discussed in comments: You can't. You can only modify the properties that get generated into the html since that is all JS has access to.
 
Share this answer
 
Comments
ali_heidari_ 1-Apr-15 17:09pm    
I should use server side codes, like Click event, i can access to properties then. yup?!
ZurdoDev 1-Apr-15 20:39pm    
Yes.

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