对话框通过java脚本显示asp.net [英] dialog show asp.net by java script

查看:62
本文介绍了对话框通过java脚本显示asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All

如何使用java脚本在asp.net中显示对话框,此显示对话框文本从代码后面传递给java函数

解决方案

嗨朋友试试这个.....





 <   html     xmlns   =  http://www.w3.org/1999/ xhtml >  
< head runat = server >
< title > < / title >
< script type = text / javascript >
函数ShowDia(){
var msg = document.getElementById(<% = txtMessage.ClientID %> )值。
alert(msg);
}

< / script >
< / head >
< body >
< 表格 < span class =code-attribute> id = form1 runat = server >
< div >
输入Messa ge:
< asp:TextBox ID = txtMessage runat = server > < / asp:TextBox >
< asp:按钮 ID = btnShowDialog runat = server 文字 = 显示对话框 OnClientClick = ShowDia(); / >
< / div >
< / form >
< / body >
< / html >


下面是样品





ASPX代码



< html xmlns =http ://www.w3.org/1999/xhtml>

< head runat =server>

< title> Untitled Page< / title> ;

< / head>

< body>

< form id =form1runat =server>

< div>

< / div>

< / form>

< script>

alert(''<%= message%>'');

< / script>

< / body>

< / html>





C#代码

公共部分类MyPage:System.Web.UI.Page

{

公共字符串消息;

protected void Page_Load(object sender,EventArgs e)

{

message =服务器端消息;

}

}


最简单的解决方案:

 Response.Write(<   script     type   ='  text / javascript' > ); 
Response.Write(alert('在代码后面写这段代码。'););
Response.Write(< / script > );


Hello All
how can show dialog in asp.net by using java script and this show dialog text pass from code behind to java function

解决方案

Hi Friend Try this.....


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function ShowDia() {
            var msg = document.getElementById("<%=txtMessage.ClientID %>").value;
            alert(msg);
        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        Enter the Message :
        <asp:TextBox ID="txtMessage" runat="server"></asp:TextBox>
        <asp:Button ID="btnShowDialog" runat="server" Text="Show Dialog" OnClientClick="ShowDia();" />
    </div>
    </form>
</body>
</html>


Below is the sample


ASPX Code

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
<script>
alert(''<%=message%>'');
</script>
</body>
</html>


C# Code
public partial class MyPage : System.Web.UI.Page
{
public string message;
protected void Page_Load(object sender, EventArgs e)
{
message = "Server Side Message";
}
}


Simplest solution:

Response.Write("<script type='text/javascript'>");
Response.Write("alert('Write this code in code behind.');");
Response.Write("</script>");


这篇关于对话框通过java脚本显示asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆