Saturday, March 31, 2012

Setting link dynamically

Sam's comments were very good also.
As for casting..
dim control as Control = FindControl(reader(1).ToString())
if (control is nothing) then
'throw an exception maybe? depends whether this is exceptional or not
else if (control is HtmlImage)
dim h as HtmlImage = ctype(control, HtmlImage)
h.NavigateUrl = ...
else if (control is TextBox)
dim t as TextBox = ctype(control, TextBox)
t.Text = reader(1).ToString()
end if
Karl
http://www.openmymind.net/
http://www.fuelindustries.com/
"Morten Snedker" <fido@dotnet.itags.org.alotofsites.com> wrote in message
news:veklp2l99u9u4pvm635cs0fq7f67eb3o65@dotnet.itags.org.
4ax.com...
> Auch, you're evil! :-)
> I suppose you by rough refer to something like
> h = FindControl(reader(1).ToString)
> , which I guess you knew would produce an error due to the implicit
> type conversion, when having Option Strict set. Though, I just can't
> figure out how to do the casting that makes i work..? And I really
> tried! :-)
>
> Regards /Snedker
>
> On Tue, 2 Jan 2007 14:49:00 -0500, "Karl Seguin"
> <karlremove@dotnet.itags.org.removeopenmymindremovemetoo.andmenet> wrote:
>
>On Wed, 3 Jan 2007 08:25:39 -0500, "Karl Seguin"
<karlremove@.removeopenmymindremovemetoo.andmenet> wrote:
It was the CType thing I'd forgotten all about. Funny how it slips
when you've been away from it for only a short while.
Thanks to both you and Sam for your fine resonse.
Regards /Morten

0 comments:

Post a Comment