Solved

Enable event validation with AJAX cascading drop downs

Posted on 2010-11-10
6
1,004 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
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 

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 500 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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

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 …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 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