标签:style blog http java 使用 os io 文件
前面使用easy ui来实现了一个tabs标签(http://blog.csdn.net/yysyangyangyangshan/article/details/38307477),不过在ASP.NET中使用时发现了一个问题。<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <link href="Scripts/EasyUI/themes/icon.css" rel="stylesheet" type="text/css" /> <link href="Scripts/EasyUI/themes/default/easyui.css" rel="stylesheet" type="text/css" /> <script src="Scripts/EasyUI/jquery-1.8.0.min.js" type="text/javascript"></script> <script src="Scripts/EasyUI/jquery.easyui.min.js" type="text/javascript"></script> <script src="Scripts/EasyUI/easyui-lang-zh_CN.js" type="text/javascript"></script> <script src="Scripts/Common.js" type="text/javascript"></script> <script src="Scripts/Ajax.js" type="text/javascript"></script> </head> <body> <form id="form1" runat="server" > <div id="tabTop"> <div title="标签一" runat="server"> <table> <tr> <td> <asp:Button ID="btn1" runat="server" Text="点击1" OnClick="Tab1_Button_Click"/> </td> </tr> </table> </div> <div title="标签二" runat="server"> <table> <tr> <td> <asp:Button ID="btn2" runat="server" Text="点击2" OnClick="Tab2_Button_Click"/> </td> </tr> </table> </div> </div> </form> </body> <script type="text/javascript"> $(‘#tabTop‘).tabs({ width: $("#tabTop").parent().width(), height: "auto", onSelect: function (title) { //这是默认的选中事件,但是当执行了pageload这个也会执行 } }); //初始化—始终显示后台保存的标签 $(document).ready(function () { var tabTitle = parseInt("<%=GetSelectedTab()%>"); if (tabTitle != null && tabTitle >=0) { $("#tabTop").tabs("select", tabTitle); } $(‘#tabTop‘).bind(‘click‘, function () { buttonTabHeadClick(); }); }); //标签页点击事件 function buttonTabHeadClick() { var title = parseInt($(‘.tabs-selected‘).index()); var oldTitle =parseInt("<%=GetSelectedTab()%>"); if ( oldTitle>=0 && title == oldTitle) { return false; } var selectObj = new Object(); selectObj.SelectTabTitle = title; selectObj.OperateType = "TabTitle"; var htmlObjects = $.ajax({ type: "POST", data: selectObj, async: true, success: function (result) { }, error: function (result) { } }); return false; } </script> </html>
public partial class _Default : System.Web.UI.Page { protected static string SelectTabTitle = "0"; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { } switch (Request["OperateType"]) { case "TabTitle": SetSelectedTab(); break; default: break; } } /// <summary> /// 保存选中的tab /// </summary> private void SetSelectedTab() { SelectTabTitle = Request["SelectTabTitle"]; } /// <summary> /// 获取选中的tab /// </summary> /// <returns></returns> protected string GetSelectedTab() { return SelectTabTitle; } protected void Tab1_Button_Click(object sender, EventArgs e) { } protected void Tab2_Button_Click(object sender, EventArgs e) { } }效果如下:
JavaScript提高:005:ASP.NET使用easyUI TABS标签显示问题,布布扣,bubuko.com
JavaScript提高:005:ASP.NET使用easyUI TABS标签显示问题
标签:style blog http java 使用 os io 文件
原文地址:http://blog.csdn.net/yysyangyangyangshan/article/details/38578403