?
Solved

Enable event validation with AJAX cascading drop downs

Posted on 2010-11-10
6
Medium Priority
?
1,006 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

770 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