Hi,
Can i execute javascript code through code behind file ? if yes how can we do this.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Keyur NarkhiPosted Apr 30, 2012, 1:56 AM
There are different ways to call JS from CS.
First is you can use attribute property as below,
btnHide.Attributes.Add("onclick", "return hideButton()"); this is in page load.so when your button click,then first it will call your client side function which is JS.
Second you can call using below
string javaScript =
"";
RegisterStartupScript("Button1_ClickScript", javaScript); you can register the script.
Hope this helps
Thanks
brunda kPosted Apr 28, 2012, 1:08 AM
http://www.codeproject.com/Articles/11098/Use-Call-RegisterStartUpScript-RegisterClientScrip
Mahak GuptaPosted Apr 28, 2012, 1:05 AM