By nima

2011-04-23 10:02:21 8 Comments

I want to fire a server-side ASP.NET button click event in JavaScript. I checked the page source and the button's onclick in client side is:

WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$LoginInfo1$btnliOK", "", true, "", "", false, false));

But I have to replace ctl00$LoginInfo1$btnliOK with something like <%= btnliOK.ClientName %>. Is there a way to do that?


@Aristos 2011-04-23 10:18:42

You can get it using the Control.UniqueID Property


UniqueID gives the on page rendered name
ClientID gives the on page rendered id
ID give's the id that you can use on code behind

@scubbo 2012-08-08 08:20:53

Just wanted to say thank you for this - this solved about six hours of frustration with the jQuery validation plugin!

@Malcor 2014-05-16 14:14:21

Thank you so much, I have been doing '.ClientID.Replace("_", "$")' for ages. Which was terrible is anything was named with a _ inside.

Related Questions

Sponsored Content

27 Answered Questions

[SOLVED] Trigger a button click with JavaScript on the Enter key in a text box

10 Answered Questions

[SOLVED] jQuery checkbox checked state changed event

19 Answered Questions

[SOLVED] Frame Buster Buster ... buster code needed

9 Answered Questions

[SOLVED] Check whether a string matches a regex in JS

7 Answered Questions

[SOLVED] How to use __doPostBack()

1 Answered Questions

See data passed after onclick event from client to server in

  • 2019-04-21 20:09:26
  • Abhishek Kr Jha
  • 25 View
  • 0 Score
  • 1 Answer
  • Tags:   c# events

19 Answered Questions

[SOLVED] Get the name of an object's type

  • 2008-12-01 22:06:15
  • Ewen Cartwright
  • 722924 View
  • 1161 Score
  • 19 Answer
  • Tags:   javascript

43 Answered Questions

17 Answered Questions

[SOLVED] How to decide when to use Node.js?

7 Answered Questions

Sponsored Content