Hi,
Can i execute javascript code through code behind file ? if yes how can we do this.
Javascript code execute through .cs file.
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Mahak GuptaRank #138 · 16.2K reputationPosted Apr 27, 2012, 9:05 PM EDT
brunda kRank #3,804 · 389 reputationPosted Apr 27, 2012, 9:08 PM EDT
http://www.codeproject.com/Articles/11098/Use-Call-RegisterStartUpScript-RegisterClientScrip
Keyur Narkhi62 reputationPosted Apr 29, 2012, 9:56 PM EDT
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