Solved

Enable event validation with AJAX cascading drop downs

Posted on 2010-11-10
6
1,005 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
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 …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

728 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