出生日期和婚礼日期不应与使用csharp在asp.net中验证相同 [英] date of birth and wedding day date should not be same validate in asp.net with csharp

查看:104
本文介绍了出生日期和婚礼日期不应与使用csharp在asp.net中验证相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用csharp在asp.net中进行一个项目,在该设计页面中如下;



名称textbox1

DOB textbox2 (日历图像)当我在该日历中的日历图像选择了哪个日期被显示在文本框中时2)

移动文本框3

婚礼文本框4(日历图像)当我日历图像在该日历中选择哪个日期被显示在文本框中4)

电子邮件文本框5





还有一个插入按钮。



当我点击插入按钮时假设用户同时选择DOB和结婚日期与时间消息显示DOB相同且结婚日期不应该是同样。



用于验证如何在asp.net中使用csharp。



请帮帮我。请给出代码。

解决方案

嗨...我会提供代码,但要记住kurnal'的消息:



<前郎=c#> DateTime dtDOB = Convert.ToDateTime(textbox2.Text);
DateTime dtWED = Convert.ToDateTime(textbox4.Text);

if (dtDOB.Day == drWED.Day&& dtDOB.Month == drWED.Month&& dtDOB。年= = drWED.Year)
{
// DO NEEDFULL
}

OR

// 时间戳可能会很糟糕问题
如果(dtDOB == drWED)
{
/ / DO NEEDFULL
}


了解ASP.NET验证控件 [ ^ ]

你可以实现这使用CompareValidator Control。

查看这些文章

ASP.NET中的验证控件 [ ^ ]

ASP.NET - 验证控件 [ ^ ]


  protected   void  Calendar1_SelectionChanged( object  sender,EventArgs e)
{
TextBox2.Text = Calendar1.SelectedDate.ToShortDateString() ;
}
受保护 void Calendar2_SelectionChanged( object sender,EventArgs e)
{
TextBox4.Text = Calendar2.SelectedDate.ToShortDateString();
}
protected void insert_Click( object sender,EventArgs e)
{
string str = TextBox4.Text;
if (TextBox2.Text.Equals(str))
{
Response.Write( @ < script language ='javascript'> alert('婚礼日期和出生日期不应相同');< / script>< /跨度>);
}
其他
{
// < span class =code-comment>无论你的代码是什么

}
}


i am doing a project in asp.net with csharp,in that design page as follows;

Name textbox1
DOB textbox2(calendar image) when i calendar image in that calendar which date is selected that date is diplayed in the textbox2)
Mobile textbox3
Wedding textbox4(calendar image) when i calendar image in that calendar which date is selected that date is diplayed in the textbox4)
Email textbox5


And one insert button.

when i click the insert button suppose user choose both DOB and Wedding Date be the same that time message displays DOB and Wedding date should not be the same.

for that validation how to do in asp.net with csharp.

please help me.please give the code.

解决方案

Hi... i will provide code but remember kurnal''s message:

DateTime dtDOB = Convert.ToDateTime(textbox2.Text);
DateTime dtWED = Convert.ToDateTime(textbox4.Text);

if(dtDOB.Day == drWED.Day && dtDOB.Month == drWED.Month && dtDOB.Year == drWED.Year)
{
     // DO NEEDFULL
}

OR

// TIME STAMP MAY CRAETE PROBLEM
if(dtDOB == drWED)
{
     // DO NEEDFULL
}


Learn about ASP.NET Validation Controls[^]
You can achieve this using CompareValidator Control.
Check out these articles
Validation Controls in ASP.NET[^]
ASP.NET - Validation Controls[^]


protected void Calendar1_SelectionChanged(object sender, EventArgs e)
   {
       TextBox2.Text = Calendar1.SelectedDate.ToShortDateString();
   }
   protected void Calendar2_SelectionChanged(object sender, EventArgs e)
   {
       TextBox4.Text = Calendar2.SelectedDate.ToShortDateString();
   }
   protected void insert_Click(object sender, EventArgs e)
   {
       string str = TextBox4.Text;
       if (TextBox2.Text.Equals(str))
       {
           Response.Write(@"<script language='javascript'>alert('wedding date and birth date should not be same');</script>");
       }
       else
       {
           //whatever your code is
       }
   }


这篇关于出生日期和婚礼日期不应与使用csharp在asp.net中验证相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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