Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Option Strict Off & Sender param.

In VB .Net if I am using more than one instance of the same control having the same name then there,obviously,will be one event procedures for the same control.I can then use the "Sender" param. to access the properties of the control(for ex.,sender.text) - but only if Option Strict Off.If Option Strict On then using "sender.text" is not possible.I need help!
[361 byte] By [softraj] at [2007-11-11 8:48:59]
# 1 Re: Option Strict Off & Sender param.
Ok, we need some more info.

Does it display an error when you try to use sender.text with option strict on? Or is the property just not available.

What control are you using? And why are you having them with the same name? I presume you mean via an array? e.g. controlname(0), controlname(1), etc
xnemsis at 2007-11-11 21:46:59 >
# 2 Re: Option Strict Off & Sender param.
Option Strict On prevents implicit conversions.

So you just need to explicitly convert the Sender type to what you want it to be.

You can use the CType() function to do the conversion.

Dim t as TextBox = CTYpe(Sender, Textbox)

Now you can use t.text
edburdo at 2007-11-11 21:48:02 >
# 3 Re: Option Strict Off & Sender param.
edburdo,your solution worked.Thanks for the help.
softraj at 2007-11-11 21:49:01 >
# 4 Re: Option Strict Off & Sender param.
Sorry,I forget to give you good rating. :) :) :)
softraj at 2007-11-11 21:50:01 >