How to pass asp.net Textbox control ID from code-behind to JavaScript function?

 Posted by vishalneeraj-24503 on 12/6/2013 | Category: JavaScript Interview questions | Views: 3266 | Points: 40
Answer:

With the help of ClientId we can pass textbox control id from code-behind to Javascript function.

For Example:-

//Aspx Part
function get_value(id)

{
var value = document.getElementById(id).value;
alert(value);
}


//Code-Behind Part
ScriptManager.RegisterStartupScript(Page, typeof(Page), "message", "javascript:get_value('"+ txt_name.ClientID +"');", true);


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response