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

29 Answered Questions

16 Answered Questions

[SOLVED] How does Access-Control-Allow-Origin header work?

44 Answered Questions

11 Answered Questions

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

10 Answered Questions

[SOLVED] jQuery checkbox checked state changed event

19 Answered Questions

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

1 Answered Questions

See data passed after onclick event from client to server in

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

17 Answered Questions

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

7 Answered Questions

Sponsored Content