使用C#在asp.net中的输入框 [英] Input Box in asp.net with C#

查看:156
本文介绍了使用C#在asp.net中的输入框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

protected void Page_Load(object sender, EventArgs e)
       {

           Button1.Attributes.Add("onclick","javascript:prompt('Enter Checkbox name.')");
       }

       protected void Button1_Click(object sender, EventArgs e)
       {
           String s="Viv";
           Response.Write(s);
           s ="<script language="'javascript'">return prompt('Enter Checkbox name.','name') </script>";
           Response.Write(s);

       }



无法在s变量中获取值.



Not getting value in s variable. suggestion?

推荐答案

如果您是Web开发人员,则应该知道javascript是在客户端浏览器上执行的,而C#代码是在服务器上执行的.

您需要将javascript提示"函数返回的值分配给隐藏变量,然后在服务器事件中读取隐藏变量的值.
If you are a web developer, you should know that the javascript is executed on client browser and the C# code is executed on server.

You need to assign the value returned from the javascript ''prompt'' function to a hidden variable and then read the value of the hidden variable on a server event.


var no = prompt( ``输入要输入的复选框的数量'',``值'');

在javascript中,我将hiddenfiled设置为该输入的值,并且可以很好地工作.
var no =prompt(''Enter No of checkBox You want to Enter'',''Value'');

In javascript and i m setting hiddenfiled to value of that input and its working nicely.


这篇关于使用C#在asp.net中的输入框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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