如何将控件传递给未填充的文本框 [英] how to pass the control to unfilled textbox

查看:56
本文介绍了如何将控件传递给未填充的文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个页面中有50个文本框。我也设置了验证器。

当用户忘记填充第一个文本框并点击页面底部的按钮时,我需要将控件传递给未填充的文本框。

how为此代码?

解决方案

您好,



按钮点击事件,您可以添加以下内容代码:



  if  string  .IsNullorEmpty(TextBox1.Text))
{
TextBox1.Focus();
}





-Regards


客户端代码:



< script type =   text / JavaScript的> 

function CallMe()
{
var x = document .getElementById( textbox的id).value;
if (x == || x == null
{
alert( 缺少一些东西);
}
}
< / script>





然后你可以调用这个Javascript代码来自你的C#代码如下:



  protected   void  button_click( object  sender,EventArgs e)
{
Page.RegisterStartupScript( .GetType(), alert CallMe(); true );
}





希望有所帮助。



-Anurag


i have 50 textboxes in a page. i set validators also.
When user forgets to fill the first textbox and clicks button at the bottom of the page i need the control should pass to the unfilled textbox.
how to code for that?

解决方案

Hi,

On button click event, you can add the below code:

if(string.IsNullorEmpty(TextBox1.Text))
{
TextBox1.Focus();
}



-Regards


Client side code:

<script type="text/javascript">

function CallMe()
{
var x= document.getElementById("id of textbox").value;
if(x=="" || x==null)
{
alert("Some stuffs are missing");
}
}
</script>



Then you can call this Javascript code from your C# code behind as below:

protected void button_click(object sender, EventArgs e)
{
Page.RegisterStartupScript(this.GetType(),"alert","CallMe();",true);
}



Hope it helps.

-Anurag


这篇关于如何将控件传递给未填充的文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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