Results 1 to 2 of 2
  1. #1

    Default Help With ASP.Net User Controls


    Hi guyz...pa tabang na pud ko sa mga master diri. Exploring customize user controls sa asp.net using C# as scripting language. So heres the problem. Created a menu control for the links of the page and created another control for the iframe. Nahan ko na when a user choose a menu item the src of the iframe will change. Kabaw nko unsaon mag dynmic change but finding it hard to get the selected item from the menu user control to the iframe user control. Hope someone can help. Here's The Code.

    Menu.ascx
    Code:
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Menu.ascx.cs" Inherits="SFA_NEW_PROJECT.UserControls.Menu" %>
    
    <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" 
        onmenuitemclick="Menu1_MenuItemClick">
    </asp:Menu>
    Menu.ascx.cs
    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    
    namespace SFA_NEW_PROJECT.UserControls
    {
        public partial class Menu : System.Web.UI.UserControl
        {
            public bool isAdmin=false;
            public string sample;
            protected void Page_Load(object sender, EventArgs e)
            {
                if (IsPostBack)
                {
                }
                else
                {
                    Menu1.Items.Clear();
                    if (!(isAdmin))
                    {
                        MenuItem DashBoard = new MenuItem("DashBoard", "#");
                        Menu1.Items.Add(DashBoard);
                        MenuItem SingleChart = new MenuItem("Single Chart", "#");
                        Menu1.Items.Add(SingleChart);
                        MenuItem MultiChart = new MenuItem("Multiple Charts", "#");
                        Menu1.Items.Add(MultiChart);
                        MenuItem ChartRegistration = new MenuItem("Chart Registration", "#");
                        Menu1.Items.Add(ChartRegistration);
                        MenuItem ScreenRegistration = new MenuItem("Screen Registration", "#");
                        Menu1.Items.Add(ScreenRegistration);
                    }
                    else
                    {
                        MenuItem DashBoard = new MenuItem("DashBoard", "#");
                        Menu1.Items.Add(DashBoard);
                        MenuItem SingleChart = new MenuItem("Single Chart", "#");
                        Menu1.Items.Add(SingleChart);
                        MenuItem MultiChart = new MenuItem("Multiple Charts", "#");
                        Menu1.Items.Add(MultiChart);
                        MenuItem ChartRegistration = new MenuItem("Chart Registration", "#");
                        Menu1.Items.Add(ChartRegistration);
                        MenuItem ScreenRegistration = new MenuItem("Screen Registration", "#");
                        Menu1.Items.Add(ScreenRegistration);
                        MenuItem ManageUser = new MenuItem("Manage Users", "#");
                        Menu1.Items.Add(ManageUser);
                    }
                }
            }
    
            protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
            {
                sample="sample";
            }
    
        }
    }
    MainContent.ascx
    Code:
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MainContent.ascx.cs" Inherits="SFA_NEW_PROJECT.UserControls.MainContent" %>
    <%@ Register src=IFrame.ascx" tagname="IFrame" tagprefix="uc1" %>
    
    <uc1:IFrame ID="frame1" runat="server" />
    MainContent.ascx.cs
    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace SFA_NEW_PROJECT.UserControls
    {
        public partial class MainContent : System.Web.UI.UserControl
        {
            public string source = "Sample2.aspx";
            protected void Page_Load(object sender, EventArgs e)
            {
    
                frame1.src = source;
            }
        }
    }

  2. #2
    Junior Member
    Join Date
    Jun 2010
    Gender
    Male
    Posts
    35

    Default Re: Help With ASP.Net User Controls

    @DeathNote:
    protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
    {
    frame1.src = "your url"; // or
    frame1.src = Menu1.NavigateUrl;
    }

  3.    Advertisement

Similar Threads

 
  1. help for vb.net users?
    By krmz69 in forum Programming
    Replies: 2
    Last Post: 06-29-2010, 09:00 PM
  2. Help at asp.net [vb]
    By tynum in forum Programming
    Replies: 51
    Last Post: 09-12-2008, 06:17 PM
  3. Need help on ASP.NET
    By shawn87chau in forum Programming
    Replies: 3
    Last Post: 08-08-2008, 05:25 AM
  4. Help with events in VB.NET
    By DeathFox in forum Programming
    Replies: 5
    Last Post: 12-17-2007, 08:07 PM
  5. Replies: 4
    Last Post: 11-04-2006, 03:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top