473,396 Members | 1,992 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,396 software developers and data experts.

RegularExpressionValidator

I have added a REV to an input type of file. I want to make sure that the
only file type that is allowed is a .gif, .jpg, or .jpeg. I develop my site
on my laptop which is running Win XP Pro and my site is hosted on a Win 2000
Advanced server. Here is my problem. When I test it on my local host of
the XP Pro machine the validator works. When I migrate it to the W2K box it
doesn't work. There is no error that is displayed. Is anyone aware of
this. Not sure if it makes a difference or not but the code is in a control
that is displayed.

Here is the code
<%@ import Namespace="ASPNET.StarterKit.Communities" %>
<%@ Register TagPrefix="community" Namespace="ASPNET.StarterKit.Communities"
Assembly="ASPNET.StarterKit.Communities" %>
<%@ Control %>
<%--

This skin is used both for adding and editing a photo. Modify the HTML
content
to modify the appearance of the page.
--%>
<community:SectionTitle CssClass="Form_Title" Runat="server"
id="SectionTitle1" />
<p class="Form_Description">Use this form to upload images to the portal.
You can
rename files before uploading them.</p>
<p>
<community:DisplayQuota runat="server" id="DisplayQuota1" />
</p>
<TABLE id="Table2" cellSpacing="0" cellPadding="3" class="Form_Table"
border="0">
<TR>
<TD class="Form_SectionRow">
Add Photo Form
<DIV></DIV>
</TD>
</TR>
<TR class="Form_LabelRow">
<TD class="Form_LabelText">
<div>
<span class="Form_LabelText">Image File </span>
<community:UploadValidator id="valUpload"
ControlToValidate="txtPhotoFile" Text="(required)" Runat="Server" />
<br>
<span class="Form_HelpText">(For example, C:\Images\Book.jpg)</span>
</div>
<input id="txtPhotoFile" type="file" Size="40" Runat="Server"><br>
<asp:RegularExpressionValidator ControlToValidate="txtPhotoFile"
ID="revTxtPhotoFile" Runat="server" ErrorMessage="Image must be a gif or
jpg/jpeg format."

ValidationExpression="(.*\.([gG][iI][fF]|[jJ][pP][gG]|[jJ][pP][eE][gG])$)"><
/asp:RegularExpressionValidator>
<br>
<community:DisplayPhotoImage id="imgPhoto" Width="100" Runat="Server" />
</TD>
</TR>
<tr>
<td class="Form_LabelText">
<asp:Panel id="pnlTopics" runat="Server">
<SPAN class="Form_LabelText">Topic</SPAN>
<asp:RequiredFieldValidator id="RequiredFieldValidator1" Runat="server"
CssClass="Form_Field" Text="(required)"
ControlToValidate="dropTopics"
InitialValue="-1"></asp:RequiredFieldValidator>
<BR>
<community:TopicPicker id="dropTopics"
runat="Server"></community:TopicPicker>
</asp:Panel>
</td>
</tr>
<TR>
<TD class="Form_LabelText">
<div>
<span class="Form_LabelText">Name </span>
<br>
<span class="Form_HelpText">(For example, 'Summer Trip')</span>
<asp:RequiredFieldValidator ControlToValidate="txtPhotoTitle"
Text="(required)" CssClass="Form_Field" Runat="server"
id="RequiredFieldValidator2" />
</div>
<asp:TextBox id="txtPhotoTitle" CssClass="Form_Field" Columns="40"
runat="server"></asp:TextBox>
<P></P>
</TD>
</TR>
<TR>
<TD class="Form_LabelText" colSpan="2">
<div>
<span class="Form_LabelText">Caption </span>
<br>
<span class="Form_HelpText">(This information is listed on the Pictures
page.)</span>
<asp:RequiredFieldValidator ControlToValidate="txtPhotoBriefDescription"
Text="(required)" Display="Dynamic"
CssClass="Form_Field" Runat="server" id="RequiredFieldValidator3" />
<community:LengthValidator Maxlength="500"
ControlToValidate="txtPhotoBriefDescription" Text="(less than 500
characters)"
CssClass="Form_Field" Runat="server" id="LengthValidator1" />
</div>
<asp:TextBox id="txtPhotoBriefDescription" CssClass="Form_Field"
runat="server" TextMode="MultiLine"
Rows="5" Width="508px"></asp:TextBox>
<P></P>
</TD>
</TR>
<TR>
<TD class="Form_LabelText" colSpan="2">
<div>
<span class="Form_LabelText">Full Description</span>
<br>
<span class="Form_HelpText">(Optional. Users can access this information
when they press the 'Read More' link.)</span>
</div>
<community:HtmlTextBox id="txtPhotoFullDescription" runat="server"
Rows="5" Width="508px" />
</TD>
</TR>
<TR>
<TD align="right" colSpan="2" class="Form_SectionRow">
<asp:Button id="btnAdd" CssClass="Form_Button" Runat="server" Text="Add
New Image"></asp:Button>
<asp:Button id="btnEdit" CssClass="Form_Button" Runat="server"
Text="Apply Changes"></asp:Button>
</TD>
</TR>
</TABLE>
<p>
</p>
Nov 18 '05 #1
1 3643
Do you have a ValidationSummary that you are using? Also, in your code
behind, if you want to validate on the server, you should explicitly do a
Page.Validate(), followed by an if (Page.IsValid) {...}.

For client side validation, you also need to make sure you have run
aspnet_regiis on the specific site you are installing to, and you need to do
this again for each new web site that you create on the server. This
installs the script libraries that are used by validation.

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"Ken Grimmett" <kg******@columbus.rr.com> wrote in message
news:2U*************@fe2.columbus.rr.com...
I have added a REV to an input type of file. I want to make sure that the
only file type that is allowed is a .gif, .jpg, or .jpeg. I develop my site on my laptop which is running Win XP Pro and my site is hosted on a Win 2000 Advanced server. Here is my problem. When I test it on my local host of
the XP Pro machine the validator works. When I migrate it to the W2K box it doesn't work. There is no error that is displayed. Is anyone aware of
this. Not sure if it makes a difference or not but the code is in a control that is displayed.

Here is the code
<%@ import Namespace="ASPNET.StarterKit.Communities" %>
<%@ Register TagPrefix="community" Namespace="ASPNET.StarterKit.Communities" Assembly="ASPNET.StarterKit.Communities" %>
<%@ Control %>
<%--

This skin is used both for adding and editing a photo. Modify the HTML
content
to modify the appearance of the page.
--%>
<community:SectionTitle CssClass="Form_Title" Runat="server"
id="SectionTitle1" />
<p class="Form_Description">Use this form to upload images to the portal.
You can
rename files before uploading them.</p>
<p>
<community:DisplayQuota runat="server" id="DisplayQuota1" />
</p>
<TABLE id="Table2" cellSpacing="0" cellPadding="3" class="Form_Table"
border="0">
<TR>
<TD class="Form_SectionRow">
Add Photo Form
<DIV></DIV>
</TD>
</TR>
<TR class="Form_LabelRow">
<TD class="Form_LabelText">
<div>
<span class="Form_LabelText">Image File </span>
<community:UploadValidator id="valUpload"
ControlToValidate="txtPhotoFile" Text="(required)" Runat="Server" />
<br>
<span class="Form_HelpText">(For example, C:\Images\Book.jpg)</span>
</div>
<input id="txtPhotoFile" type="file" Size="40" Runat="Server"><br>
<asp:RegularExpressionValidator ControlToValidate="txtPhotoFile"
ID="revTxtPhotoFile" Runat="server" ErrorMessage="Image must be a gif or
jpg/jpeg format."

ValidationExpression="(.*\.([gG][iI][fF]|[jJ][pP][gG]|[jJ][pP][eE][gG])$)">< /asp:RegularExpressionValidator>
<br>
<community:DisplayPhotoImage id="imgPhoto" Width="100" Runat="Server" /> </TD>
</TR>
<tr>
<td class="Form_LabelText">
<asp:Panel id="pnlTopics" runat="Server">
<SPAN class="Form_LabelText">Topic</SPAN>
<asp:RequiredFieldValidator id="RequiredFieldValidator1" Runat="server" CssClass="Form_Field" Text="(required)"
ControlToValidate="dropTopics"
InitialValue="-1"></asp:RequiredFieldValidator>
<BR>
<community:TopicPicker id="dropTopics"
runat="Server"></community:TopicPicker>
</asp:Panel>
</td>
</tr>
<TR>
<TD class="Form_LabelText">
<div>
<span class="Form_LabelText">Name </span>
<br>
<span class="Form_HelpText">(For example, 'Summer Trip')</span>
<asp:RequiredFieldValidator ControlToValidate="txtPhotoTitle"
Text="(required)" CssClass="Form_Field" Runat="server"
id="RequiredFieldValidator2" />
</div>
<asp:TextBox id="txtPhotoTitle" CssClass="Form_Field" Columns="40"
runat="server"></asp:TextBox>
<P></P>
</TD>
</TR>
<TR>
<TD class="Form_LabelText" colSpan="2">
<div>
<span class="Form_LabelText">Caption </span>
<br>
<span class="Form_HelpText">(This information is listed on the Pictures page.)</span>
<asp:RequiredFieldValidator ControlToValidate="txtPhotoBriefDescription" Text="(required)" Display="Dynamic"
CssClass="Form_Field" Runat="server" id="RequiredFieldValidator3" />
<community:LengthValidator Maxlength="500"
ControlToValidate="txtPhotoBriefDescription" Text="(less than 500
characters)"
CssClass="Form_Field" Runat="server" id="LengthValidator1" />
</div>
<asp:TextBox id="txtPhotoBriefDescription" CssClass="Form_Field"
runat="server" TextMode="MultiLine"
Rows="5" Width="508px"></asp:TextBox>
<P></P>
</TD>
</TR>
<TR>
<TD class="Form_LabelText" colSpan="2">
<div>
<span class="Form_LabelText">Full Description</span>
<br>
<span class="Form_HelpText">(Optional. Users can access this information when they press the 'Read More' link.)</span>
</div>
<community:HtmlTextBox id="txtPhotoFullDescription" runat="server"
Rows="5" Width="508px" />
</TD>
</TR>
<TR>
<TD align="right" colSpan="2" class="Form_SectionRow">
<asp:Button id="btnAdd" CssClass="Form_Button" Runat="server" Text="Add
New Image"></asp:Button>
<asp:Button id="btnEdit" CssClass="Form_Button" Runat="server"
Text="Apply Changes"></asp:Button>
</TD>
</TR>
</TABLE>
<p>
</p>

Nov 18 '05 #2

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

Similar topics

0
by: Andy Eshtry | last post by:
I have a radio button list, a textbox representing SIN or EIN based on my radio button list selection so I put 2 regularexpressionvalidator to evaluate the value of textbox. EIN must be (for...
3
by: Ricardo Corsi P. Cesar | last post by:
Hi, i looking for example in asp.net (VB) to make the RegularExpressionValidator in runtime in my code behind. I found some similars codes, but nothing in VB.. thanks!
3
by: DC | last post by:
I have this snippet: <tr> <td align="left">E-mail</td> <td> <asp:TextBox id="txtEmail" runat="server" MaxLength="100"></asp:TextBox>&nbsp; <asp:RegularExpressionValidator id="revEmail"...
0
by: Matt Morris | last post by:
Hello: I have a RegularExpressionValidator control attached to a TextBox. I have the ValidationExpression property set to a very simple validation expression (\w+). The validation always fails...
3
by: tshad | last post by:
I have a RegularExpressionValidator that doesn't seem to work correctly if you don't enter anything. In the following, it works correctly if you have at least 1 character. If you just enter...
0
by: venkat Murthy | last post by:
Hi, I have 10 regularexpression validators in my datagrid. my datagrid looks like; first5controls | boundcolumn | next5controls. Regularexpressionvalidator for first five controls works...
1
by: franz | last post by:
does anybody tell me why it doesn't works?? in any case gg beame true thanks franz Dim y As RegularExpressionValidator = New RegularExpressionValidator y.ValidationExpression =...
1
by: John Yopp | last post by:
I'm trying to use a asp:RegularExpressionValidator to validate the strength of a password. When I test the regular expression with Regex.IsMatch, it works perfectly. However, when used within a...
4
by: simonZ | last post by:
I have RegularExpressionValidator which validate one text box. When my text box is validated on client I would like to do something else. Is there some client event of RegularExpressionValidator?...
4
by: =?Utf-8?B?Y3VyaW91cw==?= | last post by:
I am using a RegularExpressionValidator to validate a TextBox. I use "^?+(\.*)?$" to check for a real number. The control works fine as long as the user enters something in the TextBox; it does not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.