S
Steven K
Hello, I am trying to learn how to use Code Behind. Essentially, the
example of Block 1 and Block 2 are the same. The difference is that in
Block 1 I explicitly set the parameter value to "menu_help". When I open
the menu.aspx page and Call LoadMenu(), the value from the variable
"strMenu" will populate the html table.
However, with Block 2, I am sending the value "menu_help" using Call
LoadMenu("menu_help"). When I use the statement response.write(strMenu &
"from code behind<br>") in the Code Behind page, the variable information
for "strMenu" will show on the top of the page, but it won't show up in my
table.
Any help with this would be appreciated.
--
Thanks in advance,
Steven
************ Block 1 *************
Public Class DataConnection : Inherits Page
Public Sub LoadMenu()
'Declare Parameters for Stored Procedure
Dim spMenu As OleDb.OleDbDataReader
Dim prmMenu As OleDbParameter
Dim cmdMenu As New OleDb.OleDbCommand("sp_web_Search", cnnSearch)
Dim strRepeat As String
cmdMenu.CommandType = CommandType.StoredProcedure
'Menu Structure
prmMenu = cmdMenu.Parameters.Add("@strParm01", OleDbType.VarChar) :
prmMenu.Value = "FindWebMenu"
prmMenu = cmdMenu.Parameters.Add("@strParm02", OleDbType.VarChar) :
prmMenu.Value = "menu_help"
spMenu = cmdMenu.ExecuteReader()
Do While spMenu.Read
strMenu = strMenu & spMenu("WebMenuTitle_ID")
Loop
spMenu.Close() : spMenu = Nothing
response.write(strMenu & "from code behind<br>")
End Sub
End Class
Menu.aspx
------------
<%@ Page Inherits="DataConnection" src="../../bin/cnnPricing.vb"
Explicit="True" Debug="True"%>
Sub Page_Load(Sender As Object, E As EventArgs)
If Not IsPostBack
Call LoadMenu()
response.write(strMenu & "hello Steven<br>")
....
End Sub
<div align="left" class="menu">
<table summary="" cellpadding="0" cellspacing="0" class="menu">
<tr><td><div align="left"> </div></td></tr>
<tr><td><div align="left"><%= strMenu %></div></td></tr>
</table></div><br><br>
************ Block 2 *************
Public Class DataConnection : Inherits Page
Public Sub LoadMenu(strMenu As String)
'Declare Parameters for Stored Procedure
Dim spMenu As OleDb.OleDbDataReader
Dim prmMenu As OleDbParameter
Dim cmdMenu As New OleDb.OleDbCommand("sp_web_Search", cnnSearch)
Dim strRepeat As String
cmdMenu.CommandType = CommandType.StoredProcedure
'Menu Structure
prmMenu = cmdMenu.Parameters.Add("@strParm01", OleDbType.VarChar) :
prmMenu.Value = "FindWebMenu"
prmMenu = cmdMenu.Parameters.Add("@strParm02", OleDbType.VarChar) :
prmMenu.Value = "menu_help"
spMenu = cmdMenu.ExecuteReader()
Do While spMenu.Read
strMenu = strMenu & spMenu("WebMenuTitle_ID")
Loop
spMenu.Close() : spMenu = Nothing
response.write(strMenu & "from code behind<br>")
End Sub
End Class
Menu.aspx
-----------
<%@ Page Inherits="DataConnection" src="../../bin/cnnPricing.vb"
Explicit="True" Debug="True"%>
Sub Page_Load(Sender As Object, E As EventArgs)
If Not IsPostBack
Call LoadConnection()
Call LoadMenu("menu_help")
....
End Sub
<div align="left" class="menu">
<table summary="" cellpadding="0" cellspacing="0" class="menu">
<tr><td><div align="left"> </div></td></tr>
<tr><td><div align="left"><%= strMenu %></div></td></tr>
</table></div><br><br>
example of Block 1 and Block 2 are the same. The difference is that in
Block 1 I explicitly set the parameter value to "menu_help". When I open
the menu.aspx page and Call LoadMenu(), the value from the variable
"strMenu" will populate the html table.
However, with Block 2, I am sending the value "menu_help" using Call
LoadMenu("menu_help"). When I use the statement response.write(strMenu &
"from code behind<br>") in the Code Behind page, the variable information
for "strMenu" will show on the top of the page, but it won't show up in my
table.
Any help with this would be appreciated.
--
Thanks in advance,
Steven
************ Block 1 *************
Public Class DataConnection : Inherits Page
Public Sub LoadMenu()
'Declare Parameters for Stored Procedure
Dim spMenu As OleDb.OleDbDataReader
Dim prmMenu As OleDbParameter
Dim cmdMenu As New OleDb.OleDbCommand("sp_web_Search", cnnSearch)
Dim strRepeat As String
cmdMenu.CommandType = CommandType.StoredProcedure
'Menu Structure
prmMenu = cmdMenu.Parameters.Add("@strParm01", OleDbType.VarChar) :
prmMenu.Value = "FindWebMenu"
prmMenu = cmdMenu.Parameters.Add("@strParm02", OleDbType.VarChar) :
prmMenu.Value = "menu_help"
spMenu = cmdMenu.ExecuteReader()
Do While spMenu.Read
strMenu = strMenu & spMenu("WebMenuTitle_ID")
Loop
spMenu.Close() : spMenu = Nothing
response.write(strMenu & "from code behind<br>")
End Sub
End Class
Menu.aspx
------------
<%@ Page Inherits="DataConnection" src="../../bin/cnnPricing.vb"
Explicit="True" Debug="True"%>
Sub Page_Load(Sender As Object, E As EventArgs)
If Not IsPostBack
Call LoadMenu()
response.write(strMenu & "hello Steven<br>")
....
End Sub
<div align="left" class="menu">
<table summary="" cellpadding="0" cellspacing="0" class="menu">
<tr><td><div align="left"> </div></td></tr>
<tr><td><div align="left"><%= strMenu %></div></td></tr>
</table></div><br><br>
************ Block 2 *************
Public Class DataConnection : Inherits Page
Public Sub LoadMenu(strMenu As String)
'Declare Parameters for Stored Procedure
Dim spMenu As OleDb.OleDbDataReader
Dim prmMenu As OleDbParameter
Dim cmdMenu As New OleDb.OleDbCommand("sp_web_Search", cnnSearch)
Dim strRepeat As String
cmdMenu.CommandType = CommandType.StoredProcedure
'Menu Structure
prmMenu = cmdMenu.Parameters.Add("@strParm01", OleDbType.VarChar) :
prmMenu.Value = "FindWebMenu"
prmMenu = cmdMenu.Parameters.Add("@strParm02", OleDbType.VarChar) :
prmMenu.Value = "menu_help"
spMenu = cmdMenu.ExecuteReader()
Do While spMenu.Read
strMenu = strMenu & spMenu("WebMenuTitle_ID")
Loop
spMenu.Close() : spMenu = Nothing
response.write(strMenu & "from code behind<br>")
End Sub
End Class
Menu.aspx
-----------
<%@ Page Inherits="DataConnection" src="../../bin/cnnPricing.vb"
Explicit="True" Debug="True"%>
Sub Page_Load(Sender As Object, E As EventArgs)
If Not IsPostBack
Call LoadConnection()
Call LoadMenu("menu_help")
....
End Sub
<div align="left" class="menu">
<table summary="" cellpadding="0" cellspacing="0" class="menu">
<tr><td><div align="left"> </div></td></tr>
<tr><td><div align="left"><%= strMenu %></div></td></tr>
</table></div><br><br>