Search EggHeadCafe's Job Board
EggHeadCafe Silverlight WPF ASP.NET VB.NET C# Excel SQL Server SharePoint
search
SharePoint GroupsView
Sharepoint Portalserver
Sharepoint Portalserver Development
Sharepoint Windowsservices
Sharepoint Windowsservices Development
Sharepoint Design_And_Customization
Sharepoint Development_And_Programming
Sharepoint General
Sharepoint Setup_And_Administration

Group SummariesView
.NET Framework
Access
BizTalk
Certifications
CRM
DDK
Exchange Server
FoxPro
French
French .NET
Games
German
German .NET
Graphic Design
IIS
Internet
ISA Server
Italian
Italian .NET
Maps
MCIS
Miscellaneous
Mobile Apps
Money
MSN
Networking
Office
Ops Mgr
Publisher
Security
SharePoint
Small Business
Spanish
Spanish .NET
SQL Server
Systems Management Server
Transaction Server
Virtual PC / Virtual Server
Visual Studio
Win32
Windows 2000
Windows 2003 Server
Windows 7
Windows Live
Windows Media
Windows Update
Windows Vista
Windows XP
 

View All Microsoft Sharepoint Windowsservices Development Posts  Ask A New Question 

RequiredFieldValidator control

Vinn posted on Thursday, February 01, 2007 12:41 PM

I am creating webpart for Sharepoint 2007.

I have written following code
on CreateChildControls() method
fieldVal = new RequiredFieldValidator();
fieldVal.ID = txtemail.ID + "_Val";
fieldVal.ControlToValidate = txtemail.ID;
fieldVal.EnableClientScript = true;

fieldVal.ErrorMessage = " Test";
fieldVal.InitialValue = "Zero";
fieldVal.Display =
System.Web.UI.WebControls.ValidatorDisplay.Dynamic;
//fieldVal.SetFocusOnError = txtemail;
Controls.Add(fieldVal);
also i have render control in renderwebpart  method.
when i m submitting page validation control doesn't not validate page.
--
Vinni |
reply

 

RequiredFieldValidator control

lukezha posted on Thursday, February 01, 2007 10:28 PM

------=_NextPart_0001_2C95AC73
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hello Vinni,

When you said it didn't validate the page, do you mean the error message
didn't display? And it only display its initial value "Zero"? And, how
didn't you submit the form, by clicking a button on same web part?

If the problem is that that error message doesn't displayed, I suggest you
may check the HTML source code on the client side, is the validate control
rendered correctly on the client side, and is the TextBox' ID string same
as the value you set to the validate control in web part?

Sincerely,

Luke Zhang

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


------=_NextPart_0001_2C95AC73
Content-Type: text/x-rtf
Content-Transfer-Encoding: 7bit

{\rtf1\ansi\ansicpg936\deff0\deflang1033\deflangfe2052{\fonttbl{\f0\fnil\fprq2\fcharset0 MS Sans Serif;}}
\viewkind4\uc1\pard\lang2052\f0\fs20 Hello Vinni,
\par
\par When you said it didn't validate the page, do you mean the error message didn't display? And it only display its initial value "Zero"? And, how didn't you submit the form, by clicking a button on same web part?
\par
\par If the problem is that that error message doesn't displayed, I suggest you may check the HTML source code on the client side, is the validate control rendered correctly on the client side, and is the TextBox' ID string same as the value you set to the validate control in web part?
\par
\par Sincerely,
\par
\par Luke Zhang
\par
\par Microsoft Online Community Support
\par ==================================================
\par Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notifications.
\par
\par Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx.
\par ==================================================
\par
\par This posting is provided "AS IS" with no warranties, and confers no rights.
\par
\par
\par
\par }
------=_NextPart_0001_2C95AC73--
reply

Thank you for your response. I actually figured out the mistake I was doing.

Vinn posted on Friday, February 02, 2007 7:11 AM

Thank you for your response. I actually figured out the mistake I was doing.
I had ErrorMessage property set but not the Text property. When I add another
line as fieldVal.Text = "Test Error Text Message"; then it validate and
showed the error message as "Test Error Text Message". I believe if you do
not have Text property set then it will not work. (I know this works fine in
normal asp.net pages but here it is SharePoint Web Parts)

fieldVal = new RequiredFieldValidator();
fieldVal.ID = txtemail.ID + "_Val";
fieldVal.ControlToValidate = txtemail.ID;
fieldVal.EnableClientScript = true;

fieldVal.ErrorMessage = " Test";
fieldVal.Text = "Test Error Text Message";
fieldVal.InitialValue = "Zero";
fieldVal.Display =
System.Web.UI.WebControls.ValidatorDisplay.Dynamic;
//fieldVal.SetFocusOnError = txtemail;
Controls.Add(fieldVal);

I hope this information will help others.

Thanks again.
--
Vinni | www.Laksha.net
reply

 
 

Previous Microsoft Sharepoint Windowsservices Development conversation.