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

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

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;

//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