Posted by (JavaScript must be enabled to view this email address) on Wed 21 Jan 2009
Chances are if you have developed a web part in the past, it needed some user input. And if it needed user input then it needs validation.
When you develop webparts you are unable to do use the designer (thanks Microsoft) so you have to be a real coder and declare, instantiate and add the controls entirely programmatically. Including your validation controls. Ok, you’ve done that. Why doesn’t your validation work?
First, you MUST (and I cant stress that enough) instantiate the validators in your overridden OnInit method, not in the CreateChildControls() method. Secondly, set up a validation group so that you can control what the validators are validating (you dont want to validate the whole page) and lastly, you need to ensure that the EnableClientScript property is enabled.
regexpval.ControlToValidate = this.txtEmail.ID;
regexpval.ValidationExpression = @”\w+([-+.’]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*”;
regexpval.ErrorMessage = “Please Enter a valid email address.”;
regexpval.Display = ValidatorDisplay.Dynamic;
regexpval.EnableClientScript = true;
regexpval.ValidationGroup = validationGroup;
If you’ve been diligent then your code will compile, deploy and even let you place it on the page, but for some weird reason it still doesn’t work as you think it should. AAAAARGH!
Its a small and very simple fix, the text box you are validating might be instantiated but it doesn’t have an ID, D’oh!
All it takes is adding a line like this BEFORE you set up the validators:
txtEmail.ID = “txtEmail”;
Posted by (JavaScript must be enabled to view this email address) on Fri 19 Dec 2008
You’ve spent the past four days writing the best code in the world to interface with MOSS 2007 and its publishing features. You run it and Argghhhhh! Whats going on, all your publishing data is not there!
Chances are you have done something like this to get the properties:
VB
dim startDate as DateTime = Convert.ToDateTime(item.Properties(“PublishingStartDate”));
C#
DateTime startDate = Convert.ToDateTime(item.Properties[“PublishingStartDate”]);
Instead, try accessing the properties like this:
VB
dim startDate as DateTime = Convert.ToDateTime(item(“PublishingStartDate”));
C#
DateTime startDate = Convert.ToDateTime(item[“PublishingStartDate”]);
Now get back to that killer code and get it fixed!
Posted by (JavaScript must be enabled to view this email address) on Mon 24 Nov 2008
Ok, so you have developed your funky new SharePoint master page and new personal site template. You have set up all the permissions in the SSP to allow users to edit their own profiles and take the headache away from you.
But…
When a user clicks on Edit on the user display page they only see their network account listed. How do you fix it?
First, its nothing you did wrong with permissions or settings. Its down to the way that WSS and MOSS co-exist on the machine.
The resolution is really simple:
* navigate to the 12\templates\layouts hive
* rename the useredit.aspx file to useredit.old.aspx
* copy the editprofile.aspx file and rename the copy to useredit.aspx
Your users will now have a fully functioning profile editing page.