如何使用jquery树RSS从主页Web表单重定向到另一个Web表单 [英] how to redirect from home web form to another web form using jquery tree RSS

查看:60
本文介绍了如何使用jquery树RSS从主页Web表单重定向到另一个Web表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





i希望在延迟加载概念中加载我的树视图,因为我有大量数据。



所以,我使用以下链接

通过WCF REST服务加载ASP.NET延迟内容 [ ^ ]



效果很好。但是如何重定向到另一个Web表单并且应该维护点击的节点。



我需要所有网页的treeview。所以我把Jqeury功能放在母版页中



site.master

Hi,

i wanted to load my treeview in lazy loading concept as i have large amount of data.

so, i used this following link
ASP.NET Lazy Content Loading Through WCF REST Service[^]

It works great. But how to redirect to another web form and should maintain clicked node.

i need treeview for all web pages. so i put Jqeury function and in master page

site.master

<head runat="server">
<title></title>
<link href="CSS/Jquery.css" rel="stylesheet" type="text/css" />

<script src="Script/jquery.js" type="text/javascript"></script>

<script src="Script/ui.core.js" type="text/javascript"></script>

<script language="jscript" src="Script/jquery.dynatree.js" type="text/javascript"></script>

<script type='text/javascript'>
$(function () {

// --- Initialize sample trees
$("#tree").dynatree({
title: "Lazy Tree",
rootVisible: true,
fx: { height: "toggle", duration: 200 },
initAjax: {
url: "TS.svc/GetNodes/0"

},

onLazyRead: function (dtnode) {

dtnode.appendAjax({
url: "TS.svc/GetNodes/" + dtnode.data.key

});

},
onActivate: function (dtnode) {
$("#echoActive").text(dtnode.data.title);
}

});

});

</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table border="1" width="100%">
<tr>
<td id="brandid" runat="server" align="left" valign="top">
<!--treeview starts-->
<asp:ContentPlaceHolder ID="em" runat="server">
<div class="active">
Active node: <b><span id="echoActive">-</span></b>
</div>
<div class="container">
<div id="tree">
</div>
</div>
</asp:ContentPlaceHolder>
</td>
<td width="1064px" valign="top">
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
</table>
</div>

</form>
</body>



ii)LazyTree.cs //实体类。


ii) LazyTree.cs // entity class.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace LazyLoading
{
public class TreeNode
{
/// <summary>
/// Title of the Node
/// </summary>
public string title { get; set; }
/// <summary>
/// Parent node of leaf node.
/// </summary>
public bool isFolder { get; set; }// to fetch child records
/// <summary>
/// Lazy loading enabled or not.
/// </summary>
public bool isLazy { get; set; }
/// <summary>
/// Hidden id of the Node
/// </summary>
public string key { get; set; }
}
}



iii)WCF服务-Ajax enabled.cs


iii) WCF service -Ajax enabled.cs

using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Collections.Generic;
using System.Threading;
using System.Data;
using System.Data.SqlClient;
using System.Web;

namespace LazyLoading
{
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(
RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class TS
{
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "GetNodes/{key}",
BodyStyle = WebMessageBodyStyle.Bare)]

public List<TreeNode> GetNodes(string key)
{
Thread.Sleep(100);

string NodeTitle = string.Empty;
//Generate the title of the node
List<TreeNode> collection = new List<TreeNode>();
if (key.Equals("0")) // Binding root node where all root has 0 in DataBase
{
DataTable dt = new DataTable();
if (System.Web.HttpContext.Current.Session["dtvalue"] == null)
{
SqlConnection con = new SqlConnection("data source=xxx;initial catalog=xxx;user id=xx;password=xxx");
SqlCommand cmd = new SqlCommand("select child_id , descript from cattabl where parent = 0 ", con);
SqlDataAdapter adap = new SqlDataAdapter(cmd);

adap.Fill(dt);
System.Web.HttpContext.Current.Session["dtvalue"] = dt;
}
else
{
dt = (DataTable)System.Web.HttpContext.Current.Session["dtvalue"];
}

TreeNode ts = new TreeNode();

foreach (DataRow dr in dt.Rows)
{
// NodeTitle = dr["descript"].ToString().Trim();
key = dr["child_id "].ToString().Trim();

NodeTitle = dr["descript"].ToString().Trim();

collection.Add(
new TreeNode()
{
isFolder = true,
isLazy = true,

key = string.Format("{0}", key),
title = string.Format("{0}",
NodeTitle)
});

}
}

else // Binding child node and do fetch with parent node accoring parent and child id in DataBase
{
DataTable dt = new DataTable();
string childval = key;
SqlConnection con = new SqlConnection("data source=LTC.LEESTOOLS.COM,2433;initial catalog=wftools;user id=sa2;password=15848D!c");
SqlCommand cmd = new SqlCommand("select child_id ,descript from tabval where parent ='"+childval+"' ", con);
SqlDataAdapter adap = new SqlDataAdapter(cmd);

adap.Fill(dt);
System.Web.HttpContext.Current.Session["child"] = dt;
foreach (DataRow dr in dt.Rows)
{
//dt = (DataTable)System.Web.HttpContext.Current.Session["child"];

key = dr["child_id "].ToString().Trim();

NodeTitle = dr["descript"].ToString().Trim();

collection.Add(
new TreeNode()
{
isFolder = true,
isLazy = true,

key = string.Format("{0}", key),
title = string.Format("{0}",
NodeTitle)
});
}
}

return collection;
}
}
}



就是这样。现在我有两个名为home.aspx和product.aspx的网页表单。



我将home.aspx作为启动页面。因此,在运行(f5)之后,在Home.aspx中我有树视图,如果点击任何特定节点,它会获取其子节点并正确扩展。



注意:< b>< span id =echoActive> - < / span>< / b> //它是母版页因此当我们点击节点时,它会花费它的子节点(使用url:TS.svc / GetNodes /+ dtnode.data.key)并使用

onActivate:function(dtnode)显示在span上单击的节点){

$(#echoActive)。text(dtnode.data.title);

}。





直到现在一切正常。(在同一页面内,它正常工作所有关于树cllopse,扩展等的功能..)



需要的要求:



现在当我们点击节点时,它会调用wcf服务类来绑定它的子节点并显示span类的被点击节点在home.aspx。





但我需要点击任何节点,同样的工作必须做,它应该重新切换到product.aspx并且应该维护treeview并且它的子节点有扩展。



需要帮助。







更正了f ormatting和/或语法问题。

已添加标签。

[/编辑]

推荐答案

function (){

// ---初始化样本树


#tree)。dynatree({
title: 懒树
rootVisible: true
fx:{height: toggle,duration: 200 } ,
initAjax:{
url: TS.svc / GetNodes / 0

},

onLazyRead: function (dtnode){

dtnode。 appendAjax({
url: TS.svc / GetNodes / + dtnode.data.key

});

},
onActivate: function (dtnode){
("#tree").dynatree({ title: "Lazy Tree", rootVisible: true, fx: { height: "toggle", duration: 200 }, initAjax: { url: "TS.svc/GetNodes/0" }, onLazyRead: function (dtnode) { dtnode.appendAjax({ url: "TS.svc/GetNodes/" + dtnode.data.key }); }, onActivate: function (dtnode) {


#echoActive)。text(dtnode.data.title);
}

});

});

< / script >
< / head >
< 正文 >
< 表格 id = form1 runat = 服务器 >
< div >
< border = 1 width = 100% < span class =code-keyword>>
< tr >
< td id = brandid runat = server align = left valign = top >
<! - 树视图开始 - >
< asp:ContentPlaceHolder ID = em runat = server >
< div class = active >
活动节点:< b > < span id = echoActive > - < < span class =code-leadattribute> / span > < / b >
< < span class =code-leadattribute> / div >
< div class = 容器 >
< div id = >
< / div >
< / div >
< / asp:ContentPlaceHolder >
< / td >
< td width = 1064px valign = top >
< ; asp:ContentPlaceHolder ID = ContentPlaceHolder2 runat = server >
< / asp:ContentPlaceHolder >
< / td >
< / tr >
< / table >
< < span class=\"code-leadattribute\">/div>

< ;/form>
</body>
("#echoActive").text(dtnode.data.title); } }); }); </script> </head> <body> <form id="form1" runat="server"> <div> <table border="1" width="100%"> <tr> <td id="brandid" runat="server" align="left" valign="top"> <!--treeview starts--> <asp:ContentPlaceHolder ID="em" runat="server"> <div class="active"> Active node: <b><span id="echoActive">-</span></b> </div> <div class="container"> <div id="tree"> </div> </div> </asp:ContentPlaceHolder> </td> <td width="1064px" valign="top"> <asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server"> </asp:ContentPlaceHolder> </td> </tr> </table> </div> </form> </body>



ii) LazyTree.cs // entity class.


ii) LazyTree.cs // entity class.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace LazyLoading
{
public class TreeNode
{
/// <summary>
/// Title of the Node
/// </summary>
public string title { get; set; }
/// <summary>
/// Parent node of leaf node.
/// </summary>
public bool isFolder { get; set; }// to fetch child records
/// <summary>
/// Lazy loading enabled or not.
/// </summary>
public bool isLazy { get; set; }
/// <summary>
/// Hidden id of the Node
/// </summary>
public string key { get; set; }
}
}



iii) WCF service -Ajax enabled.cs


iii) WCF service -Ajax enabled.cs

using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Collections.Generic;
using System.Threading;
using System.Data;
using System.Data.SqlClient;
using System.Web;

namespace LazyLoading
{
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(
RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class TS
{
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "GetNodes/{key}",
BodyStyle = WebMessageBodyStyle.Bare)]

public List<TreeNode> GetNodes(string key)
{
Thread.Sleep(100);

string NodeTitle = string.Empty;
//Generate the title of the node
List<TreeNode> collection = new List<TreeNode>();
if (key.Equals("0")) // Binding root node where all root has 0 in DataBase
{
DataTable dt = new DataTable();
if (System.Web.HttpContext.Current.Session["dtvalue"] == null)
{
SqlConnection con = new SqlConnection("data source=xxx;initial catalog=xxx;user id=xx;password=xxx");
SqlCommand cmd = new SqlCommand("select child_id , descript from cattabl where parent = 0 ", con);
SqlDataAdapter adap = new SqlDataAdapter(cmd);

adap.Fill(dt);
System.Web.HttpContext.Current.Session["dtvalue"] = dt;
}
else
{
dt = (DataTable)System.Web.HttpContext.Current.Session["dtvalue"];
}

TreeNode ts = new TreeNode();

foreach (DataRow dr in dt.Rows)
{
// NodeTitle = dr["descript"].ToString().Trim();
key = dr["child_id "].ToString().Trim();

NodeTitle = dr["descript"].ToString().Trim();

collection.Add(
new TreeNode()
{
isFolder = true,
isLazy = true,

key = string.Format("{0}", key),
title = string.Format("{0}",
NodeTitle)
});

}
}

else // Binding child node and do fetch with parent node accoring parent and child id in DataBase
{
DataTable dt = new DataTable();
string childval = key;
SqlConnection con = new SqlConnection("data source=LTC.LEESTOOLS.COM,2433;initial catalog=wftools;user id=sa2;password=15848D!c");
SqlCommand cmd = new SqlCommand("select child_id ,descript from tabval where parent ='"+childval+"' ", con);
SqlDataAdapter adap = new SqlDataAdapter(cmd);

adap.Fill(dt);
System.Web.HttpContext.Current.Session["child"] = dt;
foreach (DataRow dr in dt.Rows)
{
//dt = (DataTable)System.Web.HttpContext.Current.Session["child"];

key = dr["child_id "].ToString().Trim();

NodeTitle = dr["descript"].ToString().Trim();

collection.Add(
new TreeNode()
{
isFolder = true,
isLazy = true,

key = string.Format("{0}", key),
title = string.Format("{0}",
NodeTitle)
});
}
}

return collection;
}
}
}



That is all. Now i have two web form called home.aspx and product.aspx.



i gave home.aspx as startup page. SO, after run(f5), in Home.aspx i have treeview and if click any particular node, it fetches its child and extended correctly.



Note : <b><span id=\"echoActive\">-</span></b> // it is master page. so when we click on node, it expended it’s child(using url: \"TS.svc/GetNodes/\" + dtnode.data.key) and shows clicked node on span using

onActivate: function (dtnode) {


That is all. Now i have two web form called home.aspx and product.aspx.

i gave home.aspx as startup page. SO, after run(f5), in Home.aspx i have treeview and if click any particular node, it fetches its child and extended correctly.

Note : <b><span id="echoActive">-</span></b> // it is master page. so when we click on node, it expended it's child(using url: "TS.svc/GetNodes/" + dtnode.data.key) and shows clicked node on span using
onActivate: function (dtnode) {


这篇关于如何使用jquery树RSS从主页Web表单重定向到另一个Web表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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