[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Enable event validation with AJAX cascading drop downs

Posted on 2010-11-10
6
Medium Priority
?
1,009 Views
Last Modified: 2012-05-10
My question is regarding the solution on this page http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_25373688.html

I have implemented the solution but when I try to reference the controls after a postback they are not available.

Eg.
 
   Protected Sub bSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bSearch.Click

       ....

       If nvddl1.SelectedValue <> "" Then id = nvddl1.SelectedValue
       ....

    End Sub

Gives the error Object reference not set to an instance of an object.

Thanks,
Karen
0
Comment
Question by:KarenMcC
  • 3
  • 3
6 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 34111889
What is Nothing (nvddl1 or SelectedValue)?  How are you binding the CascadingDropDown?  Is is a dynamic or static control?
0
 

Author Comment

by:KarenMcC
ID: 34115471
nvddl1 is nothing.

This is example code:

    Private nvddl1 As NoValidationDropDownList
    Private nvddl2 As NoValidationDropDownList
    Private cdd1 As AjaxControlToolkit.CascadingDropDown
    Private cdd2 As AjaxControlToolkit.CascadingDropDown

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

        nvddl1 = New NoValidationDropDownList()
        nvddl1.ID = "nvddl1"
        ph1.Controls.Add(nvddl1)

        cdd1 = New AjaxControlToolkit.CascadingDropDown()
        cdd1.ID = "cdd1"
        cdd1.TargetControlID = "nvddl1"
        cdd1.Category = "country"
        cdd1.ServicePath = "~/RegionService.asmx"
        cdd1.ServiceMethod = "GetCountries"
        cdd1.SelectedValue = 4
        ph1.Controls.Add(cdd1)

        nvddl2 = New NoValidationDropDownList()
        nvddl2.ID = "nvddl2"
        ph1.Controls.Add(nvddl2)

        cdd2 = New AjaxControlToolkit.CascadingDropDown()
        cdd2.ID = "cdd2"
        cdd2.TargetControlID = "nvddl2"
        cdd2.ParentControlID = "nvddl1"
        cdd2.Category = "region"
        cdd2.ServicePath = "~/RegionService.asmx"
        cdd2.ServiceMethod = "GetRegionsForCountry"
        ph1.Controls.Add(cdd2)


    End Sub

I would prefer to add the control in design, but do not know how to do that.

Thanks.
k.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 34117640
Is NoValidationDropDownList your own custom extender/control?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:KarenMcC
ID: 34118145
Yes...

Public Class NoValidationDropDownList
    Inherits DropDownList
End Class

The only purpose of this is so that the control is not validated by EnableEventValidation="true".
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 34119666
Is this a "custom control" or a "user control"?  If it is a custom control, I would create another control library project, put the custom control into the library, and create a project reference.  The Visual Studio.NET IDE should recognize this, and add the control to the tool box, so that you can drag and drop.
0
 

Author Comment

by:KarenMcC
ID: 34133037
Thanks very much. This works very well.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question