Welcome to WebmasterWorld Guest from 18.206.168.65

Forum Moderators: ocean10000

Message Too Old, No Replies

Need in help in loading pages from usercontrol menu to iframe

     
10:11 am on Jul 28, 2009 (gmt 0)

New User

5+ Year Member

joined:June 10, 2009
posts: 9
votes: 0


I currently able to load up the link navigaton using one of the user control in the file dey have given
but, the major problem that have been surrounding is


when I click at one of the link 'Rates for Various Transport Services - > under Logistics

but when I waneted load up that page in the iframe..instead, it load navigation to the new page instead.

So how i do make it lik, when i click dat link ''Rates for Various Transport Services - > under Logistics', it will load in the iframe, instead of loading to another page

Meanwhile here is the coding for the aspx file

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Facilities1.aspx.vb" Inherits="Facilities" %>

<%@ Register src="../UserControl/Common/HMenu.ascx" tagname="HMenu" tagprefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat=server>
<title>Facilities Management</title>
<link rel="stylesheet" type="text/css" href="<%=me.resolveurl("~/scripts/css/cssversion001.css")%>" />
</head>
<body>
<form id="form1" runat="server">
<div>
<table width="100%">
<tr>
<td>
<asp:Panel runat="server" ID="Panel_Title" Visible="true">
<asp:Label ID="Label2" runat="server" Text="Faciities Management" Font-Bold="True" Font-Names="Arial" Font-Size="X-Large" ForeColor="#FF8080"></asp:Label>

<uc1:HMenu ID="HMenu1" runat="server" />

</asp:Panel>
</td>
</tr>

<tr>
<td>
<table width="100%" height="100%" cellpadding="0" cellspacing="0">
<tr>

<td style="background-repeat:repeat;" nowrap>
<iframe id="frames" runat="server" name="Frame1" frameborder=0 scrolling=auto
style="width: 885px; height: 452px" noresize=noresize

src="http://steets-intranet/apps/app_facilities/forms/pettycash-claims.htm"
visible="True"></iframe>

</td>

</tr>
</table>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

This is the aspx.vb

Imports Microsoft.VisualBasic
Imports STENG_DBConnection
Imports System.Data
Imports System.Data.SqlClient

Partial Class Facilities
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Response.Cache.SetCacheability(HttpCacheability.NoCache)

Response.Cache.SetExpires(DateTime.Now)

If Page.IsPostBack = False Then
Me.HMenu1.TurnOnLink = True
Me.HMenu1.Target0 = "Frame1"
Me.HMenu1.SystemID = 106
End If

End Sub

End Class

P.S The navigation link is taken out from the database instead of hardcoding..

Thanks in advance. (:

1:53 pm on July 28, 2009 (gmt 0)

Administrator

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month

joined:Jan 14, 2004
posts:864
votes: 3


The way to do it is to set the target of the anchors to the name of the iframe "Frame1".
4:03 pm on July 28, 2009 (gmt 0)

New User

5+ Year Member

joined:June 10, 2009
posts:9
votes: 0


Any help in answering which anchors should i set the target at?
7:36 pm on July 28, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 1, 2005
posts:732
votes: 0


Any help in answering which anchors should i set the target at?

Most likely the links you mention here, just set the attribute target="Frame1" in the anchor tag.

when I click at one of the link 'Rates for Various Transport Services - > under Logistics...
1:23 am on July 29, 2009 (gmt 0)

New User

5+ Year Member

joined:June 10, 2009
posts: 9
votes: 0


Hmm.But the only problem facing is, those links that u see on the above is taken out from a linked table of a database under a particular server. In which the links are not hard-coded..

And now the situation is, I wanted in the way the link is clicked, it is directed to the iframe but instead it navigate to the page.

I've also check out that in the iframe attributes, it doesn't have the "target" attributes in it..

so any help in answering in which part of the coding I should make any amendments or any codes that I should keyed in?

[edited by: marcel at 4:45 am (utc) on July 29, 2009]
[edit reason] removed links [/edit]

4:42 am on July 29, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 1, 2005
posts:732
votes: 0


The target attribute needs to be set in the anchor (link) and not the iFrame.

Could you post the code from the user control which is generating the links?

5:10 am on July 29, 2009 (gmt 0)

New User

5+ Year Member

joined:June 10, 2009
posts: 9
votes: 0


Okaes. Sure..

This is the usercontrol that Im using now..HMenu.ascx

Here is the coding for the HMenu.ascx

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="HMenu.ascx.vb" Inherits="HMenu" %>
<asp:Panel ID="Panel_TreeMenu" runat="server" Style="z-index: 0;position:static;" Visible="true">
<asp:TextBox ID="TextBox1" runat="server" Visible="false"></asp:TextBox>
<asp:Menu ID="Menu_MenuItems" runat="server" Orientation="Horizontal"
DisappearAfter="1000" ItemWrap="false" >
<DynamicMenuStyle CssClass=menub HorizontalPadding="5px" VerticalPadding="0px" BackColor="White" Font-Size="12px" />
<StaticMenuItemStyle HorizontalPadding="0px" VerticalPadding="0px" CssClass="menua" Font-Size="12px"/>
<DynamicMenuItemStyle BackColor="White" BorderStyle="Solid" BorderWidth="1px" BorderColor="#DEE6FD" Font-Size="12px" HorizontalPadding="0px" VerticalPadding="0px" Font-Names="Verdana"/>
</asp:Menu>

<hr />
</asp:Panel>

Here is the coding for the HMenu.ascx.vb

Imports System.Data
Imports System.Web.UI
Imports Intranet

Partial Class HMenu
Inherits System.Web.UI.UserControl

Dim clsMenu_Obj As New clsMenu

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Session("authenticate") Is Nothing Then
Response.Redirect("~/login.aspx?SystemID=" + SystemID.ToString)
End If
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetExpires(DateTime.Now)

If Page.IsPostBack = False Then
MenuGenerator()
End If
End Sub

Private Sub MenuGenerator()
If Session("authenticate") Is Nothing Then
Response.Redirect("~/login.aspx?SystemID=" + SystemID.ToString)
End If

Dim clsAuth As clsAuthentication
clsAuth = DirectCast(Session("authenticate"), clsAuthentication)

Dim dt As New DataTable
Dim clsIntranetSystem_obj As New clsIntranetSystem
Dim clsAccessRights_Obj As New clsIntranetAccessRights
Dim clsMenuitems_obj As New clsMenuItems
Dim clsmenu_obj As New clsMenu
Dim clsIntranetMenu_obj As New clsIntranetMenu

dt = clsAccessRights_Obj.GetAccessRightsID(SystemID, clsAuth.StaffData.Staff_ID, clsAuth.StaffData.Staff_Project, clsAuth.StaffData.Staff_CostCentre)
If dt.Rows.Count > 0 Then
' Configure The Menu
clsmenu_obj.dt = clsIntranetMenu_obj.DBSelect(SystemID, "activestatus")
Menu_MenuItems.Items.Clear()
clsmenu_obj.TurnOn_Link = True
clsmenu_obj.Menu1 = Menu_MenuItems
clsmenu_obj.AddMenu(0, DirectCast(Nothing, MenuItem), "Main")
End If
End Sub

Public Property SystemID() As String
Get
Return TextBox1.Text
End Get
Set(ByVal value As String)
TextBox1.Text = value
MenuGenerator()
End Set
End Property

Public Property TurnOnLink() As Boolean
Get
Return clsMenu_Obj.TurnOn_Link
End Get
Set(ByVal value As Boolean)
clsMenu_Obj.TurnOn_Link = value
End Set
End Property

Public Property Target0() As String
Get
Return clsMenu_Obj.Target0
End Get
Set(ByVal value As String)
clsMenu_Obj.Target0 = value
End Set
End Property
End Class

8:12 am on July 29, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 1, 2005
posts:732
votes: 0


When adding a MenuItem to a standard asp:Menu you can set the 'target' property, ie:

Dim menuItem As New MenuItem
menuItem.NavigateUrl = "~/myPage.aspx"
menuItem.Target = "Frame1"
menuItem.Text = "MyText"

Menu1.Items.Add(menuItem)

If I am not mistaken, it looks like you are using custom Menu and MenuItem controls:

Dim clsMenuitems_obj As New clsMenuItems
Dim clsmenu_obj As New clsMenu

You will need to find out what they are doing with the target attribute.

10:08 am on July 29, 2009 (gmt 0)

New User

5+ Year Member

joined:June 10, 2009
posts: 9
votes: 0


Hmm.Yup. I'm using this two classes
Dim clsMenuitems_obj As New clsMenuItems
Dim clsmenu_obj As New clsMenu

Meanwhile for the clsMenu, it is loading the categoryfrom the system category
For the clsMenuitems, it is loading the menu (this is where the links that I refering came out from) based from the foreign key of the system category

Here is the coding for both the clsMenu and clsMenuItems:

clsMenu:

Imports Microsoft.VisualBasic
Imports System.data
Public Class clsMenu
Private _dt As New DataTable
Private _menu As New Menu
Private _intranetSystemID As String = ""
Private _intranetAccessRightsDT As DataTable
Private _TurnOn_Link As Boolean = False
Private _Target0 As String = ""

Property TurnOn_Link() As Boolean
Get
Return _TurnOn_Link
End Get
Set(ByVal value As Boolean)
_TurnOn_Link = value
End Set
End Property
Property IntranetSystemID() As String
Get
Return _intranetSystemID
End Get
Set(ByVal value As String)
_intranetSystemID = value
End Set
End Property
Property IntranetAccessRightsDT() As DataTable
Get
Return _intranetAccessRightsDT
End Get
Set(ByVal value As DataTable)
_intranetAccessRightsDT = value
End Set
End Property
Property dt() As DataTable
Get
Return _dt
End Get
Set(ByVal value As DataTable)
_dt = value
End Set
End Property

Property Menu1() As Menu
Get
Return _menu
End Get
Set(ByVal value As Menu)
_menu = value
End Set
End Property

Property Target0() As String
Get
Return _Target0
End Get
Set(ByVal value As String)
_Target0 = value
End Set
End Property

Sub AddMenu(ByVal ParentID As Integer, ByVal mItem As MenuItem, Optional ByVal Type As String = "")
Dim dv As New DataView(dt)
Dim row As DataRowView

' Filter The Record
dv.RowFilter = "ParentID = " + ParentID.ToString

For Each row In dv
Dim item As New MenuItem
item.Text = "&nbsp;" + row("Name0").ToString + "&nbsp;"
item.Value = row("ID").ToString

If TurnOn_Link And row("Link0").ToString.Trim <> "" Then
item.NavigateUrl = row("Link0").ToString
End If
If Target0 <> "" Then
item.Target = Target0
End If
If Type = "Main" Then
item.SeparatorImageUrl = "~/images/design/Separator/Top.png"
ElseIf Type = "Sub" Then
item.SeparatorImageUrl = "~/images/design/Separator/Left.png"
End If
If mItem Is Nothing Then
Menu1.Items.Add(item)
AddMenu(Convert.ToInt16(row("ID")), item)
Else
mItem.ChildItems.Add(item)
AddMenu(Convert.ToInt16(row("ID")), item, Type)
End If
Next
End Sub
End Class

clsMenuItems:

Imports Microsoft.VisualBasic
Imports System.Data
Imports STENG_DBConnection
Imports System.Data.SqlClient

Public Class clsMenuItems
Dim db_conn As New clsDBConnection

Function DBSelect_Menu(ByVal LayerLevel As Integer, ByVal SystemID As Integer) As DataTable
Dim dt As New DataTable
Dim local_dbConn As New SqlConnection
Dim local_sqlCommand As New SqlCommand
local_dbConn = db_conn.DBConn
local_sqlCommand.Connection = local_dbConn

local_sqlCommand.CommandText = "select * from MenuItems where LayerLevel =@xLayerLevel and SystemID =@xSystemID order by menulevel"
local_sqlCommand.CommandType = CommandType.Text
local_sqlCommand.Parameters.Add(New SqlParameter("@xLayerLevel", LayerLevel))
local_sqlCommand.Parameters.Add(New SqlParameter("@xSystemID", SystemID))

Dim sql_adapter As New SqlDataAdapter(local_sqlCommand)
sql_adapter.Fill(dt)

local_dbConn.Close()
Return dt
End Function

Function DBSelect_Menu(ByVal SystemID As Integer) As DataTable
Dim dt As New DataTable
Dim local_dbConn As New SqlConnection
Dim local_sqlCommand As New SqlCommand
local_dbConn = db_conn.DBConn
local_sqlCommand.Connection = local_dbConn

local_sqlCommand.CommandText = "select * from MenuItems where SystemID =@xSystemID order by menulevel"
local_sqlCommand.CommandType = CommandType.Text
local_sqlCommand.Parameters.Add(New SqlParameter("@xSystemID", SystemID))

Dim sql_adapter As New SqlDataAdapter(local_sqlCommand)
sql_adapter.Fill(dt)

local_dbConn.Close()
Return dt
End Function

Function DBSelect_MaxLevel() As Integer
Dim maxLevel As Integer
Dim local_dbConn As New SqlConnection
Dim local_sqlCommand As New SqlCommand
local_dbConn = db_conn.DBConn
local_sqlCommand.Connection = local_dbConn

local_sqlCommand.CommandText = "select MAX(LayerLevel) AS MaxLayer FROM Intranet.dbo.IntranetMenu"
local_sqlCommand.CommandType = CommandType.Text

Dim sql_reader As SqlDataReader = local_sqlCommand.ExecuteReader()
While sql_reader.Read()
maxLevel = Convert.ToInt32(sql_reader("MaxLayer"))
End While
local_dbConn.Close()
Return maxLevel
End Function
Function DBSelect_Menu_ByIDType(ByVal SystemID As Integer, ByVal Type As String, Optional ByVal Type_ID As String = "", Optional ByVal CostCentreID As String = "", Optional ByVal ProjectID As String = "") As DataTable
Dim dt As New DataTable
Dim local_dbConn As New SqlConnection
Dim local_sqlCommand As New SqlCommand
local_dbConn = db_conn.DBConn
local_sqlCommand.Connection = local_dbConn
If Type = "StaffID" Then
local_sqlCommand.CommandText = "SELECT COUNT(StaffDataID) AS Count, ID, IntranetSystemID, StaffDataID, ProjectID, CostCentreID, GroupID, SystemControl " + _
"FROM Intranet.dbo.IntranetAccessRights WHERE (IntranetSystemID = @SystemID) AND (StaffDataID = @StaffDataID) " + _
"GROUP BY ID, IntranetSystemID, StaffDataID, ProjectID, CostCentreID, GroupID, SystemControl"
local_sqlCommand.Parameters.Add(New SqlParameter("@SystemID", SystemID))
local_sqlCommand.Parameters.Add(New SqlParameter("@StaffDataID", Type_ID))
ElseIf Type = "GroupID" Then
local_sqlCommand.CommandText = "SELECT ID, IntranetSystemID, StaffDataID, ProjectID, CostCentreID, GroupID, SystemControl " + _
"FROM Intranet.dbo.IntranetAccessRights " + _
"WHERE (GroupID IN " + _
"(SELECT IntranetGroupID " + _
"FROM Intranet.dbo.IntranetGroupList " + _
"WHERE (StaffDataID = @StaffDataID) OR " + _
"(CostCentreID = @CostCentreID) OR " + _
"(ProjectID = @ProjectID) OR " + _
"(StaffDataID = 0) AND (CostCentreID = 0) AND (ProjectID = 0))) AND (IntranetSystemID = @IntranetSystemID)"
local_sqlCommand.Parameters.Add(New SqlParameter("@StaffDataID", Type_ID))
local_sqlCommand.Parameters.Add(New SqlParameter("@CostCentreID", CostCentreID))
local_sqlCommand.Parameters.Add(New SqlParameter("@ProjectID", ProjectID))
local_sqlCommand.Parameters.Add(New SqlParameter("@IntranetSystemID", SystemID))
ElseIf Type = "ProjectID" Then
local_sqlCommand.CommandText = "SELECT COUNT(ProjectID) AS Count, ID, IntranetSystemID, StaffDataID, ProjectID, CostCentreID, GroupID, SystemControl " + _
"FROM Intranet.dbo.IntranetAccessRights WHERE (IntranetSystemID = @SystemID) AND (ProjectID = @ProjectID) " + _
"GROUP BY ID, IntranetSystemID, StaffDataID, ProjectID, CostCentreID, GroupID, SystemControl"
local_sqlCommand.Parameters.Add(New SqlParameter("@SystemID", SystemID))
local_sqlCommand.Parameters.Add(New SqlParameter("@ProjectID", Type_ID))
ElseIf Type = "CostCentreID" Then
local_sqlCommand.CommandText = "SELECT COUNT(CostCentreID) AS Count, ID, IntranetSystemID, StaffDataID, ProjectID, CostCentreID, GroupID, SystemControl " + _
"FROM Intranet.dbo.IntranetAccessRights WHERE (IntranetSystemID = @SystemID) AND (CostCentreID = @CostCentreID) " + _
"GROUP BY ID, IntranetSystemID, StaffDataID, ProjectID, CostCentreID, GroupID, SystemControl"
local_sqlCommand.Parameters.Add(New SqlParameter("@SystemID", SystemID))
local_sqlCommand.Parameters.Add(New SqlParameter("@CostCentreID", Type_ID))
ElseIf Type = "All" Then
local_sqlCommand.CommandText = "SELECT ID, IntranetSystemID, StaffDataID, ProjectID, CostCentreID, GroupID, SystemControl " + _
"FROM Intranet.dbo.IntranetAccessRights " + _
"WHERE (IntranetSystemID = @SystemID) AND (CostCentreID = 0) AND (StaffDataID = 0) AND (ProjectID = 0) AND (GroupID = 0) " + _
"GROUP BY ID, IntranetSystemID, StaffDataID, ProjectID, CostCentreID, GroupID, SystemControl"
local_sqlCommand.Parameters.Add(New SqlParameter("@SystemID", SystemID))
End If
local_sqlCommand.CommandType = CommandType.Text
Dim sql_adapter As New SqlDataAdapter(local_sqlCommand)
sql_adapter.Fill(dt)

local_dbConn.Close()
Return dt
End Function
Function GetStrAccessRights(ByVal dt As DataTable) As String
Dim strAccessRight As String = ""
For i As Integer = 0 To dt.Rows.Count - 1
If strAccessRight = "" Then
strAccessRight = "WHERE (IntranetAccessRightsID = " + dt.Rows(i)("ID").ToString
Else
strAccessRight = strAccessRight + " OR IntranetAccessRightsID = " + dt.Rows(i)("ID").ToString
End If
Next
strAccessRight += " )"
Return strAccessRight
End Function
Function DBSelect_Menu_ByAccessRightID(ByVal SystemID As Integer, ByVal dtAccessRight As DataTable, Optional ByVal LayerLevel_Limit As String = "") As DataTable
Dim dt As New DataTable
Dim local_dbConn As New SqlConnection
Dim local_sqlCommand As New SqlCommand
local_dbConn = db_conn.DBConn
local_sqlCommand.Connection = local_dbConn
Dim strAccessRights As String
strAccessRights = GetStrAccessRights(dtAccessRight)
local_sqlCommand.CommandText = "SELECT ID, Name0, Link0, IntranetSystemID, MenuLevel, LayerLevel, ParentID, SortNo, Status0, MaxSortNumber, NewWindows " + _
"FROM Intranet.dbo.IntranetMenu " + _
"WHERE (ID NOT IN " + _
"(SELECT IntranetMenuID " + _
"FROM Intranet.dbo.IntranetDenyMenu " + _
strAccessRights + ")) AND (IntranetSystemID = @IntranetSystemID) AND (LayerLevel <= @LayerLevel) AND (Status0 = @Status) " + _
"ORDER BY MaxSortNumber"
local_sqlCommand.CommandType = CommandType.Text
local_sqlCommand.Parameters.Add(New SqlParameter("@Status", 0))
local_sqlCommand.Parameters.Add(New SqlParameter("@IntranetSystemID", SystemID))
local_sqlCommand.Parameters.Add(New SqlParameter("@LayerLevel", LayerLevel_Limit))
Dim sql_adapter As New SqlDataAdapter(local_sqlCommand)
sql_adapter.Fill(dt)

local_dbConn.Close()
Return dt
End Function

End Class

Could you help me to check why is this not happening? thanks in advance

Meanwhile, would to ask you one question:
For usercontrol.. It is known to be that particular control can be reused for quite a number of pages..
Meanwhile, when I used for other control, it can be load in other pages successfully.
But for the pages that I handling now, the usercontrol doesn't seems to work on it.
But the content and the way it works, is identical..

Thats the question which had puzzling for me for around 3 weeks.

May i know the menuitem that u listed earlier, I should apply on which page? Sorry for the inconvenience caused

1:14 am on July 30, 2009 (gmt 0)

New User

5+ Year Member

joined:June 10, 2009
posts:9
votes: 0


yup. im using menuitem and menu control
2:12 am on July 30, 2009 (gmt 0)

New User

5+ Year Member

joined:June 10, 2009
posts:9
votes: 0


is DynamicMenuStyle, staticMenustyle considered a menuitem control?
8:20 am on July 30, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 1, 2005
posts:732
votes: 0


is DynamicMenuStyle, staticMenustyle considered a menuitem control?

No they are objects which are a property of a Menu Control. See MSDN [msdn.microsoft.com] for more info.

Here is some code that works exactly like you want it to, try creating a new project and add the following:

In the HTML

<asp:Menu ID="Menu1" runat="server">
</asp:Menu>
<iframe src="" width="500" height="500" id="myFrame" name="myFrame"></iframe>

In the code behind (Page_Load)

Dim menuItem As New MenuItem
menuItem.NavigateUrl = "http://www.google.com/"
menuItem.Target = "myFrame"
menuItem.Text = "Link to Google"

Menu1.Items.Add(menuItem)

And you'll see that the Google page loads into the iframe.

10:14 am on July 30, 2009 (gmt 0)

New User

5+ Year Member

joined:June 10, 2009
posts:9
votes: 0


Thanks for the help. Erm, any possibilities of dividing the menu from a single line to double line?