Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Raising event from run-time dropdownlist

Reply
Thread Tools

Raising event from run-time dropdownlist

 
 
Andrew Morton
Guest
Posts: n/a
 
      09-19-2007
I'm creating DropDownList controls at run-time, and I've found I have to add
the onchange event myself (.Attributes.Add(...) below).

Is that the way it's meant to happen, or have I missed something that would
automatically add the onchange event?

U = New DropDownList
With U
.DataSource = dv
.DataTextField = "myChoice"
.DataValueField = "myValue"
.DataBind()
' n is the number of this control
.ID = "U_" & n.ToString
' select the current value
For k As Integer = 0 To UBound(usageValues)
If CStr(entry("usage")) = usageValues(k) Then
.SelectedIndex = k
Exit For
End If
Next
AddHandler .SelectedIndexChanged, AddressOf
ModifyUsage_SelectedIndexChanged
.Attributes.Add("onchange", "__doPostBack('U_" & n.ToString & "')")
End With

Andrew


 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      09-19-2007
you want to set AutoPostBack.

-- bruce (sqlwork.com)



Andrew Morton wrote:
> I'm creating DropDownList controls at run-time, and I've found I have to add
> the onchange event myself (.Attributes.Add(...) below).
>
> Is that the way it's meant to happen, or have I missed something that would
> automatically add the onchange event?
>
> U = New DropDownList
> With U
> .DataSource = dv
> .DataTextField = "myChoice"
> .DataValueField = "myValue"
> .DataBind()
> ' n is the number of this control
> .ID = "U_" & n.ToString
> ' select the current value
> For k As Integer = 0 To UBound(usageValues)
> If CStr(entry("usage")) = usageValues(k) Then
> .SelectedIndex = k
> Exit For
> End If
> Next
> AddHandler .SelectedIndexChanged, AddressOf
> ModifyUsage_SelectedIndexChanged
> .Attributes.Add("onchange", "__doPostBack('U_" & n.ToString & "')")
> End With
>
> Andrew
>
>

 
Reply With Quote
 
 
 
 
Andrew Morton
Guest
Posts: n/a
 
      09-20-2007
> Andrew Morton wrote:
>> I'm creating DropDownList controls at run-time, and I've found I
>> have to add the onchange event myself (.Attributes.Add(...) below).
>>
>> Is that the way it's meant to happen, or have I missed something
>> that would automatically add the onchange event?


bruce barker wrote:
> you want to set AutoPostBack.


Aha! Thanks

Andrew


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Raising an Event from a UserControl contained in an IFRAME? Jeremy Howard ASP .Net 0 02-17-2004 12:46 AM
Raising an Event from a UserControl contained in an IFRAME? Jeremy Howard ASP .Net 0 02-15-2004 12:44 AM
Enter Key submition is not raising the command event Jitu ASP .Net 0 12-24-2003 09:19 AM
Re: raising event Kevin Spencer ASP .Net 0 07-31-2003 02:26 PM
Raising an Event via Code Dane Dickey ASP .Net 2 07-01-2003 07:18 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57