Thursday, March 29, 2012
Server SIde Validation Issue
I have several client side validation controls that cause an error message to be displayed in the validation summary control.
For one control, custom control, I am required to do SERVER SIDE VALIDATION.
I have the follwing code:
protected void validatePass_ServerValidate(object source, ServerValidateEventArgs args)
{
if (txtPass.Text != "Mohit")
{ validatePass.IsValid = false;
validatePass.ErrorMessage = "Wrong Password!";
}
else validatePass.IsValid = true;
}
When I enter the wrong password though I do not see the custom control generate any error message and I do not see any error message in the summary control either.
Any assisatance would be appreciated.When the wrong password is entered and the user submits the page, in the page load event or the button click event, do a check for if(Page.IsValid)
I appreciate your response.
I am afraid that I am a newbie and will need a little bit of help here.
Can you provide some pseudo code as to what I should do and can you please make any modifications to the code I provided if necessary.
Thanks!
Let's deal with this in a single thread, yeah?
http://www.vbforums.com/showthread.php?t=491694
(Since they're related questions)
Tuesday, March 13, 2012
Server.MapPath
I was using Server.MapPath to check if a file existed in the current domain and then display it so it would be displayed inwww.domainA.com/Pictures/PictureName.jpg
but now I want to check if the file exists on the same server, but in a different folder, which would be a different domain. I tried using an absolute url for the path but that didn't work. How would you do this?
Here's what I have now. Thanks
// Display the product's image if it has one
if (System.IO.File.Exists(Server.MapPath("Pictures/" + ProductLabel.Text +".jpg")) !=false){
ProductImage.ImageUrl = ("Pictures/" + ProductLabel.Text +".jpg");
}
this line of code will give u return true/false
based upon the directory exits on the server.
If Directory.Exists(NewPath)
Do you want to load an image which is not in your web site directory hierarchy?
Hi rkeslar,
Generally speaking, server.mappath is designed to return the physical path for those virtue paths which areUNDER your current domain.So-- if the virture path you want to check is outside your current domain( in another project), i'm afraid you cannot use it( Imagine how are you going to write the virtue path part??)
If you do want to check if a certain folder/file exist or not , simply using System.IO.File.Exists(physicalpath) will do it.But i'm assuming you have already known the physical path.
Hope my suggestion helps