本文為大家介紹下js如何解決彈窗問題實現班級跳轉DIV,具體示例如下,感興趣的朋友可以參考下
1、js代碼如下: 代碼如下: <%--實現班級跳轉DIV--%> <div id="displayClassDiv" style="display:none;" class="gp_box"> <ul> <% for(int i=0;i<dtPTC.Rows.Count;i++) { if (dtPTC.Rows[i]["ISPRO"].ToString() == "1") { %> <li> <h1 class="gp_title" > <span id='<%=dtPTC.Rows[i]["ProjectID"].ToString() %>'><%=dtPTC.Rows[i]["ProjectName"].ToString() %></span></h1> <% for (int j = 0; j < dtPTC.Rows.Count; j++) { if (dtPTC.Rows[i]["ProjectID"].ToString() == dtPTC.Rows[j]["ProjectID"].ToString() && dtPTC.Rows[j]["ISPRO"].ToString() == "2") { %> <dl class="gp_list" > <dt id='<%=dtPTC.Rows[j]["TermID"].ToString() %>'><%=dtPTC.Rows[j]["TermName"].ToString().Trim() %></dt> <dd class="grap"> <% int p_count = 0; for (int k = 0; k < dtPTC.Rows.Count; k++) { if (dtPTC.Rows[k]["ISPRO"].ToString() == "3" && dtPTC.Rows[j]["TermID"].ToString() == dtPTC.Rows[k]["TermID"].ToString()) { p_count++; if (dtPTC.Rows[k]["ClassID"].ToString() == Session["CLASSID"].ToString()) { %> <input id='<%=dtPTC.Rows[k]["ClassID"].ToString() %>' type="radio" name="rd_class" value='<%=dtPTC.Rows[k]["ClassID"].ToString() %>' checked /><%=dtPTC.Rows[k]["ClassName"].ToString() %> <% }else { %> <input id='<%=dtPTC.Rows[k]["ClassID"].ToString() %>' type="radio" name="rd_class" value='<%=dtPTC.Rows[k]["ClassID"].ToString() %>' /><%=dtPTC.Rows[k]["ClassName"].ToString() %> <% } if (p_count % 2 == 0) { %><br /><% } } } %> </dd> </dl> <% } } %> </li> <% } } %> </ul> </div> <script type="text/javascript"> //顯示班級信息的函數 function ShowClassInfo() { //彈出對話框 $("#displayClassDiv").dialog({ modal: true, width: '700', height: '400', title: "請選擇跳轉班級:", overlay: { opacity: 0.5, background: "black" }, buttons: { "確定": function () { SubmitClassInfo(); }, "取消": function () { $(this).dialog("destroy"); } }, close: function (event, ui) { $(this).dialog("destroy"); } }); } function SubmitClassInfo() { var ObjClass = $('[name=rd_class]:checked'); var ClassID=ObjClass.val(); window.location.href = '../ClassPortal/ClassPortal.aspx?CLASS_ID='+ClassID; } </script> 2、cs文件代碼: 復制代碼 代碼如下: public DataTable dtPTC = new DataTable();//保存項目 項目分期 班級信息 public DataTable dtProjectInfo = new DataTable();//保存項目信息 protected void Page_Load(object sender, EventArgs e) { //原框架top頁面信息開始 //User.isSessionInvalid(); clsCurrentUser user = mm.GetSession(); USER_ID = int.Parse(user.UserID); if (Request.QueryString["ClassID"] != null) { Session["ClASSID"] = Request.QueryString["ClassID"].ToString(); classid=Session["ClASSID"].ToString(); getClassInfo(); } else { classid = Session["CLASSID"].ToString(); getClassInfo(); } //username = user.GetRealName(); username = user.UserRealName; time = DateTime.Now.ToString("yyyy年MM月dd日", DateTimeFormatInfo.InvariantInfo); //classInfo = getClassInfo(classid); //DtPD = dba.SelectT_LEARNING_PROJECT(Convert.ToInt32(Session["PROJECT_ID"].ToString().Trim())); //homepage = DtPD.Rows[0]["HOMEPAGE"].ToString().Trim(); //原框架top頁面信息結束 //獲取當前用記在本班中的權限。 string sqlRole = "select Ctype from T_PUB_USER_CLASS where ClASSID=" + Session["CLASSID"].ToString() + " and USERID=" + mm.UserID; DataTable dtRole = bdb.RunQuery(sqlRole); if (dtRole.Rows.Count > 0) { role = dtRole.Rows[0]["Ctype"].ToString(); } getALLInfo(); //根據用戶ID分別獲取項目、項目分期、班級信息 getProjectInfo();//根據用戶ID分別獲取項目 } /// <summary> /// 根據用戶ID分別獲取項目、項目分期、班級信息 /// </summary> protected void getALLInfo() { int UserID = Convert.ToInt32(mm.GetSession().UserID); string procName = "HZX_SelectCLASS_ByUserID"; SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@USER_ID", UserID) }; try { dtPTC = bdb.RunProcQuery(procName, sp); } catch (Exception ee) { Response.Redirect("../../../ErrorPage.aspx"); } }