Showing posts with label clicked. Show all posts
Showing posts with label clicked. Show all posts

Tuesday, March 13, 2012

set multiview active on selection asp:menu item

I have an asp:menu with items in it and a multiview. I want to set the multiview pane depending on which menu item is clicked. Any ideas?

thanks

Andrew

Hi, ajw

Here are references :

http://blogs.vbcity.com/mcintyre/archive/2006/11/07/6773.aspx

http://www.codeproject.com/aspnet/TabControl.asp

Hope this helps


I already have a menu set up which I want to use.

So if i have an on menu clicked method then in that I want to set the multiview pane of (whatever) to active depending on which menu item is clicked.

Thanks for the help

Andrew


ajw:

I already have a menu set up which I want to use.

So if i have an on menu clicked method then in that I want to set the multiview pane of (whatever) to active depending on which menu item is clicked.

Thanks for the help

Andrew

Hi, andrew

This is for you:

ProtectedSub Menu1_MenuItemClick(ByVal senderAsObject,ByVal eAs MenuEventArgs)Handles Menu1.MenuItemClick

MultiView1.ActiveViewIndex = Int32.Parse(e.Item.Value)

Menu1.Items(0).ImageUrl ="~/Images/HomeDisabled.jpg"

Menu1.Items(1).ImageUrl ="~/Images/ProductsDisabled.jpg"

Menu1.Items(2).ImageUrl ="~/Images/SupportDisabled.jpg"

Menu1.Items(3).ImageUrl ="~/Images/HelpDisabled.jpg"

SelectCase e.Item.Value

Case 0

Menu1.Items(0).ImageUrl ="~/Images/HomeEnabled.jpg"

Case 1

Menu1.Items(1).ImageUrl ="~/Images/ProductsEnabled.jpg"

Case 2

Menu1.Items(2).ImageUrl ="~/Images/SupportEnabled.jpg"

Case 3

Menu1.Items(3).ImageUrl ="~/Images/HelpEnabled.jpg"

EndSelect

EndSub

//////////////////////////////////////

Please tell us if there is something else you have. Thanks

Hope this helps.


Can i use a query string ? e.g. mypage.aspx?multiview=1 because the menu I have is in a masterpage and the multiview is in a content page. I have used your examples to create a working model using that method. Thankyou.

Andrew


Can i use a query string ? e.g. mypage.aspx?multiview=1 because the menu I have is in a masterpage and the multiview is in a content page. I have used your examples to create a working model using that method. But have a problem in my scenario. Thankyou.

Andrew


Hi, Andrew

Are you looking this method?

protectedvoidXXX_SelectedIndexChanged(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = Convert.ToInt32(XXX.SelectedValue);
}

Hope this helps.


It doesnt work because it always says either the menu1 or the multiview1 is undeclared because the menu is on the masterpage and the multiview on the content page.

If I have a url of

e.gg

http://www.abtecnet.com/services.aspx?view=1

http://www.abtecnet.com/services.aspx?view=2

etc

Then cant I get the query string with Response.Write(Request.QueryString("view"))

And then somehow use that number to set the active index of the multiview?

Cheers

Andrew


If Ive got

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim viewstring As String
viewstring = Request.QueryString("view")

servicemultiview.setactiveindex()
End Sub

how do I set the active index to the value of the query string based on above?

Thanks

Andrew


Done it now

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim viewstring As Int32
viewstring = Request.QueryString("view")
servicemultiview.ActiveViewIndex = viewstring
End Sub

Set selected node in Treeview control in ASP:NET 2.0 ? Anyone know this ?

Hello,

Iam using Treeview control in asp.net 2.0. But have a problem.

I use NavigateUrl BUT then viewstate is lost when clicked on a link i
the menu. And the selected node is lost.

Then i have to set the selected node manually, how can i do it ? i have
tried but without luck :(
I have posted my menu code here.

namespace DayDream.Admin.UC
{
public partial class AdminMenu : DayDreamBaseUserControl
{
public string SelectedURL;

protected void Page_Load(object sender, EventArgs e)
{
DataBind();

}

protected void PopulateNode(Object sender, TreeNodeEventArgs e)
{

// Call the appropriate method to populate a node at a
particular level.
switch (e.Node.Depth)
{
case 0:
// Populate the first-level nodes.
PopulateTopLevelNodes(e.Node);
break;
case 1:
// Populate the second-level nodes.
PopulateChildern(e.Node);
break;
default:
// Do nothing.
break;
}

}

private void PopulateTopLevelNodes(TreeNode node)
{
DayDreamBasePage basePage = new DayDreamBasePage();

for (int x = 0; x <
basePage.GetAllPages().Tables[0].Rows.Count; x++)
{
if
(basePage.GetAllPages().Tables[0].Rows[x]["ParentPageID"].ToString().Length
<= 0)
{

TreeNode TopLevel = new TreeNode();

//TopLevel.NavigateUrl =
basePage.GetAllPages().Tables[0].Rows[x]["Template"].ToString() +
"?id=" + basePage.GetAllPages().Tables[0].Rows[x]["PageID"].ToString();
TopLevel.NavigateUrl =
"../../"+basePage.GetAllPages().Tables[0].Rows[x]["Template"].ToString()
+ "?id=" +
basePage.GetAllPages().Tables[0].Rows[x]["PageID"].ToString();
TopLevel.Text =
basePage.GetAllPages().Tables[0].Rows[x]["PageName"].ToString();
TopLevel.Value =
basePage.GetAllPages().Tables[0].Rows[x]["PageID"].ToString();

// Add root node to TreeView
TopLevel.PopulateOnDemand = true;
TopLevel.SelectAction =
TreeNodeSelectAction.SelectExpand;
node.ChildNodes.Add(TopLevel);

}

}

}

private void PopulateChildern(TreeNode node)
{

DayDreamBasePage basePage = new DayDreamBasePage();

DataSet Childrens = new DataSet();
Childrens =
basePage.GetChildrenPages(Int32.Parse(node.Value)) ;

for (int y = 0; y < Childrens.Tables[0].Rows.Count; y++)
{

TreeNode newNode = new TreeNode();
newNode.NavigateUrl = "../../" +
Childrens.Tables[0].Rows[y]["Template"].ToString() + "?id=" +
Childrens.Tables[0].Rows[y]["PageID"].ToString();
newNode.Text =
Childrens.Tables[0].Rows[y]["PageName"].ToString();
newNode.Value =
Childrens.Tables[0].Rows[y]["PageID"].ToString();

// Set additional properties for the node.
newNode.SelectAction =
TreeNodeSelectAction.SelectExpand;

// Add the new node to the ChildNodes collection of the
parent node.
node.ChildNodes.Add(newNode);

DataSet ChildrensSub = new DataSet();
int ChildrensSubCount =
basePage.GetChildrenPages(Int32.Parse(newNode.Valu e)).Tables[0].Rows.Count;

if (ChildrensSubCount > 0)
{
PopulateChildern(newNode);
}

}
}

}
}

Thanks
JeppeOn Page_Load event you are not checking if Page isPostBack

If Not (Page.IsPostBack) {
DataBind();
}

Sandeep

"jesper_lofgren@.yahoo.se" wrote:

> Hello,
> Iam using Treeview control in asp.net 2.0. But have a problem.
> I use NavigateUrl BUT then viewstate is lost when clicked on a link i
> the menu. And the selected node is lost.
> Then i have to set the selected node manually, how can i do it ? i have
> tried but without luck :(
> I have posted my menu code here.
>
> namespace DayDream.Admin.UC
> {
> public partial class AdminMenu : DayDreamBaseUserControl
> {
> public string SelectedURL;
> protected void Page_Load(object sender, EventArgs e)
> {
> DataBind();
>
> }
> protected void PopulateNode(Object sender, TreeNodeEventArgs e)
> {
> // Call the appropriate method to populate a node at a
> particular level.
> switch (e.Node.Depth)
> {
> case 0:
> // Populate the first-level nodes.
> PopulateTopLevelNodes(e.Node);
> break;
> case 1:
> // Populate the second-level nodes.
> PopulateChildern(e.Node);
> break;
> default:
> // Do nothing.
> break;
> }
> }
>
> private void PopulateTopLevelNodes(TreeNode node)
> {
> DayDreamBasePage basePage = new DayDreamBasePage();
> for (int x = 0; x <
> basePage.GetAllPages().Tables[0].Rows.Count; x++)
> {
> if
> (basePage.GetAllPages().Tables[0].Rows[x]["ParentPageID"].ToString().Length
> <= 0)
> {
> TreeNode TopLevel = new TreeNode();
> //TopLevel.NavigateUrl =
> basePage.GetAllPages().Tables[0].Rows[x]["Template"].ToString() +
> "?id=" + basePage.GetAllPages().Tables[0].Rows[x]["PageID"].ToString();
> TopLevel.NavigateUrl =
> "../../"+basePage.GetAllPages().Tables[0].Rows[x]["Template"].ToString()
> + "?id=" +
> basePage.GetAllPages().Tables[0].Rows[x]["PageID"].ToString();
> TopLevel.Text =
> basePage.GetAllPages().Tables[0].Rows[x]["PageName"].ToString();
> TopLevel.Value =
> basePage.GetAllPages().Tables[0].Rows[x]["PageID"].ToString();
> // Add root node to TreeView
> TopLevel.PopulateOnDemand = true;
> TopLevel.SelectAction =
> TreeNodeSelectAction.SelectExpand;
> node.ChildNodes.Add(TopLevel);
>
> }
> }
> }
>
> private void PopulateChildern(TreeNode node)
> {
> DayDreamBasePage basePage = new DayDreamBasePage();
> DataSet Childrens = new DataSet();
> Childrens =
> basePage.GetChildrenPages(Int32.Parse(node.Value)) ;
> for (int y = 0; y < Childrens.Tables[0].Rows.Count; y++)
> {
> TreeNode newNode = new TreeNode();
> newNode.NavigateUrl = "../../" +
> Childrens.Tables[0].Rows[y]["Template"].ToString() + "?id=" +
> Childrens.Tables[0].Rows[y]["PageID"].ToString();
> newNode.Text =
> Childrens.Tables[0].Rows[y]["PageName"].ToString();
> newNode.Value =
> Childrens.Tables[0].Rows[y]["PageID"].ToString();
> // Set additional properties for the node.
> newNode.SelectAction =
> TreeNodeSelectAction.SelectExpand;
> // Add the new node to the ChildNodes collection of the
> parent node.
> node.ChildNodes.Add(newNode);
> DataSet ChildrensSub = new DataSet();
> int ChildrensSubCount =
> basePage.GetChildrenPages(Int32.Parse(newNode.Valu e)).Tables[0].Rows.Count;
> if (ChildrensSubCount > 0)
> {
> PopulateChildern(newNode);
> }
> }
> }
>
> }
> }
>
> Thanks
> Jeppe
>