473,385 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

dynamic validator images

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?

Jul 14 '06 #1
3 1368
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.

Jul 14 '06 #2
Move the code related to "img" tag into ErrorText property. This probably
would work.

<de********@gmail.comwrote in message
news:11*********************@p79g2000cwp.googlegro 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?

Jul 14 '06 #3
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.

<de********@gmail.comwrote in message
news:11*********************@p79g2000cwp.googlegro 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?
Jul 15 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: K | last post by:
I have found a script online that I want to use (I am new to PHP). It creates dynamic images based on the text that you pass it. However, no matter how I try, I can't get anything other than a...
3
by: JOSEPHINE ALVAREZ | last post by:
I have this code that I want to use to do a rollover. However, because the company I am doing it for is continually changing the text, I want to be able to use dynamic text to change the text on...
1
by: coollzh | last post by:
i have a asp.net Form with serval input textbox and serval validators to validate the user input dynamic when user input wrongly in the textbox, the validator will worn the user for wrong inputing...
1
by: Luis Ferrao | last post by:
Hi, To understand the problem, a small description of the situation should be provided: I have a Field Control that is made of a one row table with three columns. The table width is 100%, the...
3
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum....
3
by: rgparkins | last post by:
Hi I am currently having problems with Validators in a user control. I am creating a wizard sign-up process which have the allocated step (hyperlinks" at the top of the page. A user can also...
0
by: Mike Collins | last post by:
I have a form where I create dynamic controls at runtime. With this, I am adding a dynamic required field validators to each control as needed, but the validators are not firing when I click...
2
by: Mike Collins | last post by:
I have a form where I create dynamic controls at runtime. With this, I am adding a dynamic required field validator to each control as needed, but the validators are not firing when I click submit....
0
by: Eniac | last post by:
Hi, I've been working on a custom user control that needs to be modified and the validation is causing me headaches. The control used to generate a table of 4 rows x 7 columns to display all...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.