Hi,
Thanks for your helpful tutorial and this nascent forum.
mY PRESENT SCENARIO:
I have a aspx page(say question1.aspx) in which I have menu buttons on the left and right and content in the middle.
Now, the left menu is rendered by using an #include inside question.aspx and calls another page(say left_menu.aspx) which has a series of if,then else statements and depending on certain session variables, the menu shows buttons with either a check mark or just a plain button.
Ideally, on page load of left_menu.aspx , I need to perform a database call...retrieve some values and then assign these values to session variables.Depending on the contents of the session variables, I could show the desired menu buttons.
The problem here is that, since am using #include to call left_menu.aspx, I cannot use a @page directive inside left_menu.aspx, since only a single @page can be used and it is already used at the calling question1.aspx
I could call the function on page load of my main question1.aspx and it would work, but, that would mean I will have to go and include that code on about 60 other pages, which am trying to avoid.
This is when I stumbled onto using user controls.
So on my Question1.aspx page, I have
<%@ Register TagPrefix="fmleftmenuuc" TagName="fmleft109" Src="./LeftMenuUserControl.ascx" %>
and
<form id="form1" defaultbutton="Button1" runat="server" autocomplete="off">
<div id="page" style="z-index: 102; left: 0px; top: 0px; height: 800px">
<div id="mastery1" style="z-index: 102; left: 0px; width: 788px; position: absolute; top: 0px">
<!--#INCLUDE FILE="mastery1.aspx" -->
</div>
<fmleftmenuuc:fmleft109 runat="server" id="Leftmenu1" />
and on my LeftMenuUserControl.ascx page, I have:
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="LeftMenuUserControl.ascx.vb" Inherits="LeftMenuUserControl" %>
<div class="menulefttop">
<a href="../home.aspx"> Home</a>
<p><strong> Management</strong></p>
</div>
<% if (Session("Q_NO1") = 1) then %>
<a href="Question1.aspx" title="Please provide contact information"><img src="images\image_checked.jpg" /></a>
<%else%>
<a href="Question1.aspx" title="Please provide contact information "><img src="images\Question1_unchecked.jpg" /></a>
<%end if %>
<% if (Session("Q_NO2") = 1) then%>
<a href="Question2.aspx" title="Is your real property policy management great?"><img src="images\image2_checked.jpg" /></a>
<%else%>
<a href="Question2.aspx" title="Please provide contact information "><img src="images\image2_unchecked.jpg"/></a>
<%end if %>
and in the code behind file, I have:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'To change the left menu with tick for answered questions
Dim myConn As OracleConnection
Dim conn As String
Dim myCmd As OracleCommand
'Set conn equal to the conn. string we setup in the web.config
conn = ConfigurationManager.AppSettings("Connectoracle")
myConn = New OracleConnection(conn)
myConn.Open()
'OracleConnection conn = new OracleConnection(CONNECTSTRING);
Dim myuserx As String = Session("useriod")
myCmd = New OracleCommand("SELECT DISTINCT QUESTION_NO FROM MGMNT WHERE USER_ID=" + "'" + myuserx + "'", myConn)
Dim dr As OracleDataReader
dr = myCmd.ExecuteReader()
If dr.HasRows() Then
While (dr.Read())
Dim Q_NO As Integer
Q_NO = dr("QUESTION_NO")
If Q_NO = 1 Then
Session("Q_NO1") = 1
ElseIf Q_NO = 2 Then
Session("Q_NO2") = 1
End If
End While
End If
dr.Close()
myConn.Close()
End Sub
Ideally, I hoped the left menu will display as desired. But, its just blank space..none of my buttons show
Thanks for your helpful tutorial and this nascent forum.
mY PRESENT SCENARIO:
I have a aspx page(say question1.aspx) in which I have menu buttons on the left and right and content in the middle.
Now, the left menu is rendered by using an #include inside question.aspx and calls another page(say left_menu.aspx) which has a series of if,then else statements and depending on certain session variables, the menu shows buttons with either a check mark or just a plain button.
Ideally, on page load of left_menu.aspx , I need to perform a database call...retrieve some values and then assign these values to session variables.Depending on the contents of the session variables, I could show the desired menu buttons.
The problem here is that, since am using #include to call left_menu.aspx, I cannot use a @page directive inside left_menu.aspx, since only a single @page can be used and it is already used at the calling question1.aspx
I could call the function on page load of my main question1.aspx and it would work, but, that would mean I will have to go and include that code on about 60 other pages, which am trying to avoid.
This is when I stumbled onto using user controls.
So on my Question1.aspx page, I have
<%@ Register TagPrefix="fmleftmenuuc" TagName="fmleft109" Src="./LeftMenuUserControl.ascx" %>
and
<form id="form1" defaultbutton="Button1" runat="server" autocomplete="off">
<div id="page" style="z-index: 102; left: 0px; top: 0px; height: 800px">
<div id="mastery1" style="z-index: 102; left: 0px; width: 788px; position: absolute; top: 0px">
<!--#INCLUDE FILE="mastery1.aspx" -->
</div>
<fmleftmenuuc:fmleft109 runat="server" id="Leftmenu1" />
and on my LeftMenuUserControl.ascx page, I have:
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="LeftMenuUserControl.ascx.vb" Inherits="LeftMenuUserControl" %>
<div class="menulefttop">
<a href="../home.aspx"> Home</a>
<p><strong> Management</strong></p>
</div>
<% if (Session("Q_NO1") = 1) then %>
<a href="Question1.aspx" title="Please provide contact information"><img src="images\image_checked.jpg" /></a>
<%else%>
<a href="Question1.aspx" title="Please provide contact information "><img src="images\Question1_unchecked.jpg" /></a>
<%end if %>
<% if (Session("Q_NO2") = 1) then%>
<a href="Question2.aspx" title="Is your real property policy management great?"><img src="images\image2_checked.jpg" /></a>
<%else%>
<a href="Question2.aspx" title="Please provide contact information "><img src="images\image2_unchecked.jpg"/></a>
<%end if %>
and in the code behind file, I have:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'To change the left menu with tick for answered questions
Dim myConn As OracleConnection
Dim conn As String
Dim myCmd As OracleCommand
'Set conn equal to the conn. string we setup in the web.config
conn = ConfigurationManager.AppSettings("Connectoracle")
myConn = New OracleConnection(conn)
myConn.Open()
'OracleConnection conn = new OracleConnection(CONNECTSTRING);
Dim myuserx As String = Session("useriod")
myCmd = New OracleCommand("SELECT DISTINCT QUESTION_NO FROM MGMNT WHERE USER_ID=" + "'" + myuserx + "'", myConn)
Dim dr As OracleDataReader
dr = myCmd.ExecuteReader()
If dr.HasRows() Then
While (dr.Read())
Dim Q_NO As Integer
Q_NO = dr("QUESTION_NO")
If Q_NO = 1 Then
Session("Q_NO1") = 1
ElseIf Q_NO = 2 Then
Session("Q_NO2") = 1
End If
End While
End If
dr.Close()
myConn.Close()
End Sub
Ideally, I hoped the left menu will display as desired. But, its just blank space..none of my buttons show