0

In my form I need to insert a button and in the code behind file I am calling that button click event. While calling the button click event I am using javascript.

But the problem is when I deployed into UAT the id got changed in the code behind file. For example:

"Window.Opener.document.forms[0].ctl00_ContentPlaceHolder1_button_click();"

changes to

"Window.Opener.document.forms[0].ContentPlaceHolder1_button_click();"

I used ASP controls for button with runat = "server".

Appreciate any help! Thanks.

Sri K
  • 1
  • 1
  • The answers on this question may provide you with some information http://stackoverflow.com/questions/4437717/asp-net-2-5-prefixing-ctl00-and-asp-net-4-not-prefixing-ctl00 – Lex Webb Jan 17 '17 at 17:22
  • This is default behaviour, that is why we use [ClientID](https://msdn.microsoft.com/en-us/library/system.web.ui.control.clientid(v=vs.110).aspx) – VDWWD Jan 17 '17 at 17:31
  • Thanks for your information. Can anyone show me how can I use the ClinetID, I am not that familiar. I am using ASP button control. Please find the format of it. How Can I add ClientID here?? Can anyone help me out. – Sri K Jan 17 '17 at 18:48
  • `var yourButton = document.getElementById('<%=btn1.ClientID%>');` This is the general usage of `ClientID` – Daniel Corzo Jan 17 '17 at 19:21

1 Answers1

-1

You can execute which ever function is not undefined

(Window.Opener.document.forms[0].ctl00_ContentPlaceHolder1_button_click || Window.Opener.document.forms[0].ContentPlaceHolder1_button_click)();

Reddy
  • 87
  • 1
  • 1