Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > dynamic validator images

Reply
Thread Tools

dynamic validator images

 
 
delta.emil@gmail.com
Guest
Posts: n/a
 
      07-14-2006
Hello,

Here is my issue. I want to have validators which show an image when
the the control doesn't validate. Each user can select one of several
visual themes. For each theme the images are in a different
subdirectory.
So I need something like this:

<asp:RequiredFieldValidator ID="rfv1" Runat="server"
ControlToValidate="tx1" ErrorMessage="tx1 is empty.">
<img src='<%= GetThemeFile("error.jpg") %>' >
</asp:RequiredFieldValidator>

where GetStylesFile() is a method in a class, which all my pages
inherit and gets the proper path for an image, according to the theme
the user selected (saved in the Session).

Of course the peace of code above doesn't work (or I wouldn't be asking
for help), but I hope it illustrates what I am trying to do. Anyone
have ideas on how to achieve this?

 
Reply With Quote
 
 
 
 
delta
Guest
Posts: n/a
 
      07-14-2006
I forgot to mention - I'm using .NET framework v1.1 and I'm not allowed
to upgrade to v2, so ASP.NET 2 solutions won't help me.

 
Reply With Quote
 
 
 
 
Winista
Guest
Posts: n/a
 
      07-14-2006
Move the code related to "img" tag into ErrorText property. This probably
would work.

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Hello,
>
> Here is my issue. I want to have validators which show an image when
> the the control doesn't validate. Each user can select one of several
> visual themes. For each theme the images are in a different
> subdirectory.
> So I need something like this:
>
> <asp:RequiredFieldValidator ID="rfv1" Runat="server"
> ControlToValidate="tx1" ErrorMessage="tx1 is empty.">
> <img src='<%= GetThemeFile("error.jpg") %>' >
> </asp:RequiredFieldValidator>
>
> where GetStylesFile() is a method in a class, which all my pages
> inherit and gets the proper path for an image, according to the theme
> the user selected (saved in the Session).
>
> Of course the peace of code above doesn't work (or I wouldn't be asking
> for help), but I hope it illustrates what I am trying to do. Anyone
> have ideas on how to achieve this?
>



 
Reply With Quote
 
delta
Guest
Posts: n/a
 
      07-15-2006
Thanks Winista!

I assigned the code of the img to the Text property in the codebehind
and it worked.
rfv1.Text = GetValidatorText();
But the thing is I wanted to avoid using codebeind on this, otherwise I
could have used something like:
((HtmlImage)rfv1.Controls[0]).Src = GetThemeFile("error.jpg");

I wanted to use the GetThemeFile() method on properties of all sorts of
controls - like ImageButtons. It's a designer thing and I don't want to
put it in the codebehind.

I tried this:

<asp:RequiredFieldValidator ID="rfv1" Runat="server"
ControlToValidate="tx1" ErrorMessage="tx1 is empty."
Text='<%= GetValidatorText() %>' />

but again it doesn't work.

In fact, every time I've tried to use the <%= %> construct it has
failed. Does it ever work?

Weirdly, this works:

<% rfv1.Text = GetValidatorText(); %>
<asp:RequiredFieldValidator ID="rfv1" Runat="server"
ControlToValidate="tx1" ErrorMessage="tx1 is empty." />

But only if the <%%> block is in before the validator. What's up with
that? I thought the validator wouldn't be initialized back there.

Winista wrote:
> Move the code related to "img" tag into ErrorText property. This probably
> would work.
>
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) ups.com...
> > Hello,
> >
> > Here is my issue. I want to have validators which show an image when
> > the the control doesn't validate. Each user can select one of several
> > visual themes. For each theme the images are in a different
> > subdirectory.
> > So I need something like this:
> >
> > <asp:RequiredFieldValidator ID="rfv1" Runat="server"
> > ControlToValidate="tx1" ErrorMessage="tx1 is empty.">
> > <img src='<%= GetThemeFile("error.jpg") %>' >
> > </asp:RequiredFieldValidator>
> >
> > where GetStylesFile() is a method in a class, which all my pages
> > inherit and gets the proper path for an image, according to the theme
> > the user selected (saved in the Session).
> >
> > Of course the peace of code above doesn't work (or I wouldn't be asking
> > for help), but I hope it illustrates what I am trying to do. Anyone
> > have ideas on how to achieve this?
> >


 
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
Struts Validator - creditCard validator smrimell@gmail.com Java 4 02-13-2007 08:32 PM
Dynamic Validator Help Please =?Utf-8?B?TWlrZSBDb2xsaW5z?= ASP .Net 2 11-15-2006 06:15 PM
ASP.NET 1.1 Bug - Dynamic RE Validator =?Utf-8?B?U3RldmUgV29uZGVyZnVs?= ASP .Net 1 03-01-2006 07:58 PM
Dynamic validator Query Nergal ASP .Net 2 01-24-2005 10:55 AM
asp.net Dynamic display Validator bug!! coollzh ASP .Net 0 06-03-2004 04:19 PM



Advertisments