如何在c#编码中编写javascript函数? [英] How to write javascript function within c# coding?
问题描述
如何在asp页面的弹出窗口中显示Textbox值
Response.Write (< script type ='text / javascript'> alert('Your Invoice No is:document.getElementById(TextBox24.ClientId).Value')< / script>);
Response.Flush();
how to show Textbox value in pop up window in asp page
Response.Write("<script type='text/javascript'>alert('Your Invoice No is :document.getElementById(TextBox24.ClientId).Value')</script>");
Response.Flush();
推荐答案
只是使用这个.... :)
Just Use This....:)
Response.Write("<script>alert('"+txtTextbox.Text+"')</script>");
我想如果你只想在页面加载时显示文本框值,那么在页面加载事件中
i think if you just want to show text box value on page load then in page load event
RegisterStartupScript("ScriptSegmentName", "<script type=\"javascript\">" +
"alert(''Your Invoice No is "+TextBox24.Text+"'');" + "</script>");
就足够了。
但是如果你想在某些事件上使用相同的功能那么你需要先注册JS中该事件的事件处理程序。此事件处理程序将调用js函数,该函数将包含上面提到的相同警报行。但是这个js应该使用RegisterClientScriptBlock函数注册。
is sufficient.
But if you want same functionality on some event then you need to first register event handler for that event in JS. This event handler will call a js function which will contain the same alert line mentioned above. however this js should be registered using RegisterClientScriptBlock function.
这篇关于如何在c#编码中编写javascript函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!