Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > ByVal sender As Object, ByVal e As EventArgs - can I send more?

Reply
Thread Tools

ByVal sender As Object, ByVal e As EventArgs - can I send more?

 
 
David Lozzi
Guest
Posts: n/a
 
      07-22-2005
I have the following drop down list:

<aspropDownList id="ddDept" runat="server" DataSource='<%#
LoadDropDown("DEPT") %>' DataTextField="strName" DataValueField="strName"
AutoPostBack="True"
OnSelectedIndexChanged="UpdateText('txtDepartment' )"></aspropDownList>

and on change I would like the value of the drop down to populate a text
box. Here's the function:

Sub UpdateText(ByVal sender As Object, ByVal e As EventArgs, ByVal txt
As String)
Dim dd As DropDownList = sender
Dim tx as TextBox
tx = dd.Parent.FindControl(txt)
'tx = dd.Parent.FindControl("txtDepartment")
If dd.SelectedIndex > 0 Then
tx.Text = dd.SelectedValue
End If
End Sub

Now, i just added the references to tx as textbox and that's where I get the
issues. If I remove that and uncomment the line that finds the control it
works great! However, I have several drop downs that I want to use this
function with so I don't want to make several of the same functions.

Is there a way to send data to a Sub/function from the drop down and keep
the sender object? Is there a way to send the drop down object and another
variable to the sub/function? Something like this in Javascript works:
onchange="UpdateText(this,'txtDepartment')". Of course I don't want to use
javascript, I want it all done in the code.

Thanks!

David Lozzi


 
Reply With Quote
 
 
 
 
David Lozzi
Guest
Posts: n/a
 
      07-22-2005
Is it possible to do something like this instead?

OnSelectedIndexChanged="UpdateText(txtDepartment,d dDept)"

Function UpdateText(ByVal txt As TextBox, ByVal ddl As DropDownList)



If ddl.SelectedIndex > 0 Then

txt.Text = ddl.SelectedValue

End If

End Function


Currently, i get this error:

'AddressOf' operand must be the name of a method; no parentheses are needed


thanks!


"David Lozzi" <dlozzi@(removethis)delphi-ts.com> wrote in message
news:(E-Mail Removed)...
>I have the following drop down list:
>
> <aspropDownList id="ddDept" runat="server" DataSource='<%#
> LoadDropDown("DEPT") %>' DataTextField="strName" DataValueField="strName"
> AutoPostBack="True"
> OnSelectedIndexChanged="UpdateText('txtDepartment' )"></aspropDownList>
>
> and on change I would like the value of the drop down to populate a text
> box. Here's the function:
>
> Sub UpdateText(ByVal sender As Object, ByVal e As EventArgs, ByVal txt
> As String)
> Dim dd As DropDownList = sender
> Dim tx as TextBox
> tx = dd.Parent.FindControl(txt)
> 'tx = dd.Parent.FindControl("txtDepartment")
> If dd.SelectedIndex > 0 Then
> tx.Text = dd.SelectedValue
> End If
> End Sub
>
> Now, i just added the references to tx as textbox and that's where I get
> the issues. If I remove that and uncomment the line that finds the control
> it works great! However, I have several drop downs that I want to use this
> function with so I don't want to make several of the same functions.
>
> Is there a way to send data to a Sub/function from the drop down and keep
> the sender object? Is there a way to send the drop down object and another
> variable to the sub/function? Something like this in Javascript works:
> onchange="UpdateText(this,'txtDepartment')". Of course I don't want to use
> javascript, I want it all done in the code.
>
> Thanks!
>
> David Lozzi
>
>



 
Reply With Quote
 
 
 
 
Harolds
Guest
Posts: n/a
 
      07-22-2005
Sub ddl_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
handles ddlA.SelectedIndexChanged, ddlB.SelectedIndexChanged,
ddlC.SelectedIndexChanged
dim txt as textbox
If ctype(sender,DropDownList).SelectedIndex > 0 Then
select case ctype(sender,DropDownList).id
case "ddlA"
txt = findcontrol("txtA")
case "ddlB"
txt = findcontrol("txtB")
case "ddlC"
txt = findcontrol("txtC")
end select
txt.text = sender.selectvalue
end if



"David Lozzi" wrote:

> Is it possible to do something like this instead?
>
> OnSelectedIndexChanged="UpdateText(txtDepartment,d dDept)"
>
> Function UpdateText(ByVal txt As TextBox, ByVal ddl As DropDownList)
>
>
>
> If ddl.SelectedIndex > 0 Then
>
> txt.Text = ddl.SelectedValue
>
> End If
>
> End Function
>
>
> Currently, i get this error:
>
> 'AddressOf' operand must be the name of a method; no parentheses are needed
>
>
> thanks!
>
>
> "David Lozzi" <dlozzi@(removethis)delphi-ts.com> wrote in message
> news:(E-Mail Removed)...
> >I have the following drop down list:
> >
> > <aspropDownList id="ddDept" runat="server" DataSource='<%#
> > LoadDropDown("DEPT") %>' DataTextField="strName" DataValueField="strName"
> > AutoPostBack="True"
> > OnSelectedIndexChanged="UpdateText('txtDepartment' )"></aspropDownList>
> >
> > and on change I would like the value of the drop down to populate a text
> > box. Here's the function:
> >
> > Sub UpdateText(ByVal sender As Object, ByVal e As EventArgs, ByVal txt
> > As String)
> > Dim dd As DropDownList = sender
> > Dim tx as TextBox
> > tx = dd.Parent.FindControl(txt)
> > 'tx = dd.Parent.FindControl("txtDepartment")
> > If dd.SelectedIndex > 0 Then
> > tx.Text = dd.SelectedValue
> > End If
> > End Sub
> >
> > Now, i just added the references to tx as textbox and that's where I get
> > the issues. If I remove that and uncomment the line that finds the control
> > it works great! However, I have several drop downs that I want to use this
> > function with so I don't want to make several of the same functions.
> >
> > Is there a way to send data to a Sub/function from the drop down and keep
> > the sender object? Is there a way to send the drop down object and another
> > variable to the sub/function? Something like this in Javascript works:
> > onchange="UpdateText(this,'txtDepartment')". Of course I don't want to use
> > javascript, I want it all done in the code.
> >
> > Thanks!
> >
> > David Lozzi
> >
> >

>
>
>

 
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
Application_Start(Object sender, EventArgs e) - When does it realy runs? mswc.net ASP .Net 2 04-26-2005 08:04 PM
Why are sender and object used as in sender As System.Object, ByVal e As System.EventArgs? Showjumper ASP .Net 2 08-02-2003 10:53 PM
What does (ByVal sender As System.Object, ByVal e As System.EventArgs) mean? Kathy Burke ASP .Net 2 08-01-2003 12:22 PM
How to set default to TRUE: Overrides Function OnBubbleEvent(ByVal source As Object, ByVal args As EventArgs) As Boolean? Andreas Klemt ASP .Net Building Controls 1 07-18-2003 01:03 PM
Re: How to set default to TRUE: Overrides Function OnBubbleEvent(ByVal source As Object, ByVal args As EventArgs) As Boolean? David Waz... ASP .Net 0 07-04-2003 07:32 PM



Advertisments