RPSCRB 550 30 4 2014 然后我有一个名为提交的按钮。 当我点击提交我想显示消息,如果日期不匹配。显示消息日期不匹配 如果匹配日期意味着重定向到另一页。 我的代码如下 提交代码如下 String strDt = string.Empty; ; foreach(RepeaterItem中的RepeaterItem ri) { CheckBox chk =(CheckBox)ri.FindControl(chkitem); if(chk.Checked = true) { HiddenField lbld1 =(HiddenField)ri.FindControl(hdDate); strDt = strDt + lbld1.Value +,; } } string [] strRDate = strDt.Split(','); //比较两个匹配的日期不是 if(strRDate.Length> 2) { string strResult =(strRDate [0] == strRDate [1] )? 日期匹配:日期不匹配; Response.Write(strResult); } 在运行模式下如果两个日期不匹配则表示消息日期匹配。这是正确的。 如果日期匹配意味着我想重定向到另一页。 $ b日期匹配的$ b意味着重定向到另一个页面,我该如何编写代码。 请帮帮我。 问候, Narasiman P. 解决方案 从您的问题看来,您似乎想知道哪个asp.net用于将用户重定向到代码后面的不同页面的命令。为此,您将使用Response.Redirect(URL)命令。如果我没有正确理解你,请告诉我,但我会更改以下代码 if(strRDate.Length> 2) ) { string strResult =(strRDate [0] == strRDate [1])? 日期匹配:日期不匹配; Response.Write(strResult); } TO if(strRDate.Length> 2) { if(strRDate [0] == strRDate [1])$ ​​b $ b { Response.Redirect(〜/ PageToSendTo。 ASPX); } 其他 { Response.Write(日期不匹配); } } 并将PageToSendTo.aspx替换为您希望他们去的页面的URL到。 Repeater control as followsCoursename Amount CoursedateRPST 450 29 4 2014RPSCRB 550 30 4 2014Then i have one button called submit.When i click the submit i want to show message if date are not matched. shows message date are not matchedif dates are matched means redirect to another page.For that my code as followsIn submit code as followsString strDt = string.Empty; ;foreach (RepeaterItem ri in Repeater1.Items){CheckBox chk = (CheckBox)ri.FindControl("chkitem");if(chk.Checked = true){HiddenField lbld1 = (HiddenField)ri.FindControl("hdDate");strDt = strDt + lbld1.Value + ",";}}string[] strRDate = strDt.Split(',');//comparing the both date is matched are notif (strRDate.Length > 2){string strResult = (strRDate[0] == strRDate[1]) ? "Dates are matched" : "Dates are not matched";Response.Write(strResult);}in run mode if both dates are not matched means shows the message Date are matched.it is correct.if Dates are matched means i want to redirect to another page.for dates are matched means redirect to another page for that how can i write the code.please help me.Regards,Narasiman P. 解决方案 From your question it seems that you want to know which asp.net command to use to redirect a user to a different page from code behind. For that you would use the Response.Redirect(URL) command. Please let me know if I didn't understand you correctly, but I would change the following codeif (strRDate.Length > 2){ string strResult = (strRDate[0] == strRDate[1]) ? "Dates are matched" : "Dates are not matched"; Response.Write(strResult);} TOif (strRDate.Length > 2){ if (strRDate[0] == strRDate[1]) { Response.Redirect("~/PageToSendTo.aspx"); } else { Response.Write("Dates are not matched"); }}And replace the PageToSendTo.aspx with the URL of the page you want them to go to. 这篇关于在转发器控制中,如果日期不匹配,则重定向到另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-26 23:55