Regarding this article, i have a question.
I have adapted this for ASP.Net using vb.net and am unable to access the strSelStatusVal property
It's really just a dropdown Web Control that I created for reuse. I just need to be able to access the selected value when a user clicks on it.
'*********************************************************************************************
'START WEB USER CONTROL CODE
'*********************************************************************************************
' Function: Page_Load
'=============================================================================================
Imports System.Data.SqlClient
Public Class CBOStatus
Inherits System.Web.UI.UserControl
Private strConn As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("connstring"))
Public strSelStatusVal As String
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
Dim strSQL As String
Dim drStatus As SqlDataReader
Dim cmdSelect As SqlCommand
strSQL = "SELECT ID, Status FROM Status "
cmdSelect = New SqlCommand(strSQL, strConn)
Try
strConn.Open()
drStatus = cmdSelect.ExecuteReader
ddStatus.DataSource = drStatus
ddStatus.DataTextField = "Status"
ddStatus.DataValueField = "ID"
ddStatus.DataBind()
Catch ex As Exception
End Try
End If
End Sub
'=============================================================================================
' Function: ddStatus_SelectedIndexChanged
'---------------------------------------------------------------------------------------------
Private Sub ddStatus_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddStatus.SelectedIndexChanged
strSelStatusVal = ddStatus.SelectedValue
End Sub
End Class
<%@ Control Language="vb" AutoEventWireup="false" Codebehind="CBOStatus.ascx.vb"
Inherits="IntranetSupportAppliation.CBOStatus"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
'*********************************************************************************************
'END WEB USER CONTROL CODE
'*********************************************************************************************
'*********************************************************************************************
'START WEB PAGE CONTROL CODE
'*********************************************************************************************
'vb code
Public Sub SaveTicket(ByVal sender As Object, ByVal e As System.EventArgs)
Dim CBOStatus As CBOStatus = New CBOStatus
Dim strStatusID As String = CBOStatus.strSelStatusVal
End Sub
<%@ Register TagPrefix="uc1" TagName="CBOStatus" Src="Controls/CBOStatus.ascx" %>
'*********************************************************************************************
'END WEB PAGE CONTROL CODE
'*********************************************************************************************
Of course, these are just small snippets of the actual code, but I cannot figure out why I can't access the PROPERTY strSelStatusVal