Tags: __dopostback, aspx, calling, control, controluniqueid, identify, javascript, method, net, subject, uinque
__doPostBack( <%= control.UniqueID %>, ); best method?
On .Net » .Net Technology
2,156 words with 1 Comments; publish: Sat, 05 Jan 2008 20:29:00 GMT; (10062.50, « »)
I'm using the uinque ID of a control to identify it when calling __doPostBack() in javascript, after looking at a few posts on the subject. I was just wondering if this is still the best way to identify a control as some of the posts I looked at were quite old? Is there a new method of doing this when you are using things like master pages or user controls? Here's my code:
<asp:Content runat="server" ContentPlaceHolderID="ContentPlaceHolder1"
<script type="text/javascript"
function clickButton() {
alert("button will be clicked");
//this works, need to match this control id (delimited by '$'):
//__doPostBack('ctl00$ContentPlaceHolder1$LinkButton1','');
__doPostBack('<%= LinkButton1.UniqueID%>','');
}
</script
<asp:LinkButton ID="LinkButton1" runat="server"></asp:LinkButton>
<asp:Label ID="lblDebug" runat="server"></asp:Label>
<a href="javascript: clickButton();">Click LinkButton through javascript</a>
</asp:Content>
I'd be grateful for any feedback. Thanks
http://dotnet-tech.itags.org/q_dotnet-tech_170167.html
All Comments
Leave a comment...
- 1 Comments

__doPostBack('<%= LinkButton1.UniqueID %>', '');
Afaik, that's still fine...
-LV
#1; Sat, 05 Jan 2008 20:31:00 GMT