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;
}
}
}