检查按钮上单击的文本框文本 [英] check a text box text on button click

查看:57
本文介绍了检查按钮上单击的文本框文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在aspx页面中有输入类型的文本框.我想检查按钮上单击的文本是否为"text1",然后单击按钮上将打开其他页面.


请尽可能帮助我.

hi guys,

i have input type text box in a aspx page. i want to check on button click whether the text is "text1" then on button click other page will be open.


please help me as sson as possible.

推荐答案

尝试一下.

在您的.aspx页面中

Try this.

In you .aspx page

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />



在您的.aspx.cs页面中



In your .aspx.cs page

protected void Button1_Click(object sender, EventArgs e)
   {
       if (TextBox1.Text == "text1")
       {
           Response.Redirect(url);//here url is which page you need to open
       }
       else
       {
           TextBox1.Focus();
       }
   }


搜索网络以进行客户端验证.您可能想编写一个JS函数,该函数可以对Form
的POST请求执行所需的操作
Search the net for client side validation. You would want to write a js function which does what you need to do on the POST request of Form

<FORM action="http://somesite.com/page.htm onsubmit="validateForm()"  method="post">


On button click write bellow cod

Assume the textbox id is txtbox1

   if(txtbox1.Text=="text1")
{
 
  Response.Redirect("abc.aspx");
 //Server.Transfer("xyz.aspx");

}


这篇关于检查按钮上单击的文本框文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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