accessing the readonly properties of a listmenu with a user control?

Discussion in 'ASP .Net' started by Moe Sizlak, Jul 15, 2004.

  1. Moe Sizlak

    Moe Sizlak Guest

    Hi There,

    I am trying to use the to obtain the information from 2 listmenus, if the
    user makes a selection the page is submitted and then based on the value
    selected is transfererd to another page. This works ok on it's own but I
    can't seem to access the actual value of the control or the option value
    ( <option value="6">...NT...</option>)
    ..
    Any ideas ppl?

    Moe

    !--- function returns these values to screen

    _ctl1_lstStates
    _ctl1_lstCategorie


    Public ReadOnly Property SelectedCategoriesID As String
    Get
    return lstCategorie.ClientID
    End Get
    End Property

    Public ReadOnly Property SelectedStatesID As String
    Get
    return lstStates.ClientID
    End Get
    End Property


    "redirect functions

    'strSelectedCategories = lstCategorie.ClientID.SelectedItem.Value
    'strSelectedStates = lstStates.ClientID.SelectedItem.Value

    If strSelectedStates <> "0" AND strSelectedCategories ="0" Then
    strFormID = strSelectedStates
    SendUserToState(strFormID)
    Elseif strSelectedStates = "0" AND strSelectedCategories <> "0" Then
    'response.write ("categories")
    'response.end
    strFormID = strSelectedCategories
    SendUserToCategorie(strFormID)
    End If

    End If
    End Sub

    Public Function SendUserToState(ByVal strFormID as Integer)
    Select Case strFormID
    Case 1,2,3,4,5,6,7,8,9
    response.redirect("browselistingsbystate.aspx?StateID=" & strFormID)
    Case Else
    'do jack all
    End Select
    End Function

    Public Function SendUserToCategorie(ByVal strFormID as Integer)
    Select Case strFormID
    Case 6,10,8,7,11,13,9,12
    response.redirect("browselistings.aspx?CategoryID=" & strFormID)
    Case Else
    'do jack all
    End Select
    End Function

    <td height="20" width="11%">
    <div align="right"><font face="Verdana, Arial, Helvetica, sans-serif"
    size="1" color="#FFFFFF">Browse
    :</font></div>
    </td>
    <td height="20" width="14%">

    <div align="left">
    <asp:listbox id="lstCategorie" runat="server" Rows="1"
    AutoPostBack="true"
    DataTextField="CategoryDesc" DataValueField="CategoryID" />

    </div>

    </td>
    <td height="20" width="11%">
    <div align="right"><font face="Verdana, Arial, Helvetica, sans-serif"
    size="1" color="#FFFFFF">Browse
    :</font></div>
    </td>
    <td height="20" width="14%">

    <div align="left">
    <asp:listbox id="lstStates" runat="server" Rows="1"
    AutoPostBack="true"
    DataTextField="Location" DataValueField="LocationID" />
     
    Moe Sizlak, Jul 15, 2004
    #1
    1. Advertising

  2. Moe Sizlak

    Natty Gur Guest

    Hi,

    If I get you right you need to use ListBox SelectedItem.Value to get
    current user select value.

    Public ReadOnly Property SelectedCategoriesID As String
    Get
    return lstCategorie.SelectedItem.Value
    End Get
    End Property

    HTH

    Natty Gur[MVP]

    blog : http://weblogs.asp.net/ngur
    Mobile: +972-(0)52-8888377


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Natty Gur, Jul 15, 2004
    #2
    1. Advertising

  3. Moe Sizlak

    Moe Sizlak Guest

    Hi Natty,

    The only problem is I get the error "Object reference not set to an instance
    of an object. " if I change the code to:

    How can I get around this error?

    Moe

    Public ReadOnly Property SelectedCategoriesID As String
    Get
    return lstCategorie.SelectedItem.Value
    End Get
    End Property
    Public ReadOnly Property SelectedStatesID As String
    Get
    return lstStates.SelectedItem.Value
    End Get
    End Property


    "Natty Gur" <> wrote in message
    news:...
    > Hi,
    >
    > If I get you right you need to use ListBox SelectedItem.Value to get
    > current user select value.
    >
    > Public ReadOnly Property SelectedCategoriesID As String
    > Get
    > return lstCategorie.SelectedItem.Value
    > End Get
    > End Property
    >
    > HTH
    >
    > Natty Gur[MVP]
    >
    > blog : http://weblogs.asp.net/ngur
    > Mobile: +972-(0)52-8888377
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Moe Sizlak, Jul 17, 2004
    #3
  4. Moe Sizlak

    Natty Gur Guest

    Hi,

    so the user didn't select any item. select if SelectedItem is null
    before using it.

    Natty Gur[MVP]

    blog : http://weblogs.asp.net/ngur
    Mobile: +972-(0)52-8888377


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Natty Gur, Jul 17, 2004
    #4
  5. Moe Sizlak

    Moe Sizlak Guest

    Hi Natty,

    The user did select an item, as soon as the form is submitted the error
    occurs.

    Sean
    "Natty Gur" <> wrote in message
    news:uC$...
    > Hi,
    >
    > so the user didn't select any item. select if SelectedItem is null
    > before using it.
    >
    > Natty Gur[MVP]
    >
    > blog : http://weblogs.asp.net/ngur
    > Mobile: +972-(0)52-8888377
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Moe Sizlak, Jul 17, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Craig G
    Replies:
    3
    Views:
    752
    Craig G
    Nov 30, 2004
  2. Rob Meade
    Replies:
    5
    Views:
    469
    Rob Meade
    Dec 5, 2005
  3. Max2006
    Replies:
    2
    Views:
    538
    Max2006
    Jul 13, 2007
  4. jobs
    Replies:
    0
    Views:
    523
  5. Jonathan Hyatt
    Replies:
    1
    Views:
    2,147
    Jonathan Hyatt
    Jun 8, 2004
Loading...

Share This Page