如何从javascript返回true或false返回代码

编程入门 行业动态 更新时间:2024-10-08 06:29:43
本文介绍了如何从javascript返回true或false返回代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

function confirm_meth(){ var confirm = confirm('还有更多具有相同单号的项目。你要继续吗'); if(确认== true){ 返回true; } else { 返回false; } } ScriptManager.RegisterStartupScript(Page,GetType(),confirm_meth,confirm_meth( ),true); 提交按钮代码如下 string url = string.Empty; bool isAgri = true; int count = 0; //添加 foreach(grdRpt.Rows中的GridViewRow行) { CheckBox chk =(CheckBox)grdRpt.Rows [row.RowIndex ] .FindControl(chkselecdata); if(chk.Checked == true) { count ++; int key = Convert.ToInt32(grdRpt.DataKeys [row.RowIndex] .Value); if(row.Cells [4] .Text ==Agri Input) { isAgri = true; url = ConfigurationManager.AppSettings [SAPAgriInputPostingUrl]。ToString(); } 休息; } }

function confirm_meth() { var confirmed = confirm('There are some more items with same slip number is there. Do you want to proceed'); if (confirmed == true) { return true; } else { return false; } } ScriptManager.RegisterStartupScript(Page, GetType(), "confirm_meth", "confirm_meth()", true); Submit button code as follows string url = string.Empty; bool isAgri = true; int count = 0; //added foreach (GridViewRow row in grdRpt.Rows) { CheckBox chk = (CheckBox)grdRpt.Rows[row.RowIndex].FindControl("chkselecdata"); if (chk.Checked == true) { count++; int key = Convert.ToInt32(grdRpt.DataKeys[row.RowIndex].Value); if (row.Cells[4].Text == "Agri Input") { isAgri = true; url = ConfigurationManager.AppSettings["SAPAgriInputPostingUrl"].ToString(); } break; } }

String strConnString = ConfigurationManager.ConnectionStrings["IvcSpiderDBConnectionStrings"].ConnectionString; SqlConnection con = new SqlConnection(strConnString); con.Open(); if (count > 0) { if (isAgri) { string slip_No = string.Empty; List<string> slipnoList = new List<string>(); List<dist_request> dist_requests = new List<dist_request>(); foreach (GridViewRow row in grdRpt.Rows) { CheckBox cb = (CheckBox)row.FindControl("chkselecdata"); if (cb.Checked == true) { int key = Convert.ToInt32(grdRpt.DataKeys[row.RowIndex].Value); slip_No = row.Cells[2].Text; Dist_Request dist_request = new Dist_Request(); LT_ITEMS lT_ITEM = new LT_ITEMS(); lT_ITEM.MATNR = row.Cells[15].Text == " " ? string.Empty : row.Cells[15].Text; dist_request = dist_requests.Where(r => r.SLIP_NO == slip_No).FirstOrDefault(); if (dist_request != null && dist_request.SLIP_NO != null) { dist_requests.Find(f => f.SLIP_NO == slip_No).PostingNav.Add(lT_ITEM); dist_requests.Find(f => f.SLIP_NO == slip_No).FLAG += "," + key.ToString(); } else { dist_request = new Dist_Request(); dist_request.SLIP_NO = slip_No; dist_request.BUDAT = DateTime.Now.ToString("yyyyMMdd"); dist_request.MBLNR = string.Empty; dist_request.FLAG = key.ToString(); List<lt_items> lT_ITEMs = new List<lt_items>(); List<returnnav> listreturnNav = new List<returnnav>(); lT_ITEMs.Add(lT_ITEM); dist_request.PostingNav = lT_ITEMs; dist_request.ReturnNav = listreturnNav; dist_requests.Add(dist_request); } } else { slip_No = row.Cells[2].Text; slipnoList.Add(slip_No); } } HttpHelper httpHelper = new HttpHelper(); if (dist_requests.Count > 1) { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('More than one slip no selected no');", true); return; } else { if (slipnoList.Contains(dist_requests.FirstOrDefault().SLIP_NO)) { System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(System.Web.UI.Page), "Script", "confirm_meth();", true); } In the runmode when i click the submit i get alert message as "There are some more items with same slip number is there. Do you want to proceed?" Ok Cancel. i click ok in the below line i cannot get the System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(System.Web.UI.Page), "Script", "confirm_meth();", true); retrun value what is the mistake in my above code? What I have tried: function confirm_meth() { var confirmed = confirm('There are some more items with same slip number is there. Do you want to proceed'); if (confirmed == true) { return true; } else { return false; } } ScriptManager.RegisterStartupScript(Page, GetType(), "confirm_meth", "confirm_meth()", true); Submit button code as follows string url = string.Empty; bool isAgri = true; int count = 0; //added foreach (GridViewRow row in grdRpt.Rows) { CheckBox chk = (CheckBox)grdRpt.Rows[row.RowIndex].FindControl("chkselecdata"); if (chk.Checked == true) { count++; int key = Convert.ToInt32(grdRpt.DataKeys[row.RowIndex].Value); if (row.Cells[4].Text == "Agri Input") { isAgri = true; url = ConfigurationManager.AppSettings["SAPAgriInputPostingUrl"].ToString(); } break; } } <pre> String strConnString = ConfigurationManager.ConnectionStrings["IvcSpiderDBConnectionStrings"].ConnectionString; SqlConnection con = new SqlConnection(strConnString); con.Open(); if (count > 0) { if (isAgri) { string slip_No = string.Empty; List<string> slipnoList = new List<string>(); List<dist_request> dist_requests = new List<dist_request>(); foreach (GridViewRow row in grdRpt.Rows) { CheckBox cb = (CheckBox)row.FindControl("chkselecdata"); if (cb.Checked == true) { int key = Convert.ToInt32(grdRpt.DataKeys[row.RowIndex].Value); slip_No = row.Cells[2].Text; Dist_Request dist_request = new Dist_Request(); LT_ITEMS lT_ITEM = new LT_ITEMS(); lT_ITEM.MATNR = row.Cells[15].Text == " " ? string.Empty : row.Cells[15].Text; dist_request = dist_requests.Where(r => r.SLIP_NO == slip_No).FirstOrDefault(); if (dist_request != null && dist_request.SLIP_NO != null) { dist_requests.Find(f => f.SLIP_NO == slip_No).PostingNav.Add(lT_ITEM); dist_requests.Find(f => f.SLIP_NO == slip_No).FLAG += "," + key.ToString(); } else { dist_request = new Dist_Request(); dist_request.SLIP_NO = slip_No; dist_request.BUDAT = DateTime.Now.ToString("yyyyMMdd"); dist_request.MBLNR = string.Empty; dist_request.FLAG = key.ToString(); List<lt_items> lT_ITEMs = new List<lt_items>(); List<returnnav> listreturnNav = new List<returnnav>(); lT_ITEMs.Add(lT_ITEM); dist_request.PostingNav = lT_ITEMs; dist_request.ReturnNav = listreturnNav; dist_requests.Add(dist_request); } } else { slip_No = row.Cells[2].Text; slipnoList.Add(slip_No); } } HttpHelper httpHelper = new HttpHelper(); if (dist_requests.Count > 1) { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('More than one slip no selected no');", true); return; } else { if (slipnoList.Contains(dist_requests.FirstOrDefault().SLIP_NO)) { System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(System.Web.UI.Page), "Script", "confirm_meth();", true); } In the runmode when i click the submit i get alert message as "There are some more items with same slip number is there. Do you want to proceed?" Ok Cancel. i click ok in the below line i cannot get the System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(System.Web.UI.Page), "Script", "confirm_meth();", true); retrun value what is the mistake in my above code?

推荐答案

这与提醒信息的问题相同用户确定或使用C#取消 [ ^ ]。请回复原始邮件而不是重新发布。 This is the same question as Alert message to the user ok or cancel using C#[^]. Please respond in the original message rather than reposting.

更多推荐

如何从javascript返回true或false返回代码

本文发布于:2023-11-27 21:32:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639678.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:代码   javascript   true   false

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!