Click here to Skip to main content
15,881,413 members
Home / Discussions / ASP.NET
   

ASP.NET

 
Questionplease helpme Pin
sivasampathkumar8-Jul-09 23:59
sivasampathkumar8-Jul-09 23:59 
AnswerRe: please helpme Pin
Manas Bhardwaj9-Jul-09 0:05
professionalManas Bhardwaj9-Jul-09 0:05 
AnswerRe: please helpme Pin
K03069-Jul-09 0:14
K03069-Jul-09 0:14 
AnswerRe: please helpme Pin
Abhijit Jana9-Jul-09 0:36
professionalAbhijit Jana9-Jul-09 0:36 
AnswerRe: please helpme Pin
Kevin Heathfield9-Jul-09 2:58
Kevin Heathfield9-Jul-09 2:58 
QuestionValidating File Upload Control with Regular Expression Validator Pin
meeram3958-Jul-09 23:49
meeram3958-Jul-09 23:49 
AnswerRe: Validating File Upload Control with Regular Expression Validator Pin
Manas Bhardwaj8-Jul-09 23:52
professionalManas Bhardwaj8-Jul-09 23:52 
GeneralRe: Validating File Upload Control with Regular Expression Validator Pin
meeram3959-Jul-09 1:00
meeram3959-Jul-09 1:00 
Here is the code:

<tr><td><asp:FileUpload ID="DocumentFileUpload" runat="server" />
<asp:Button ID="DocumentUploadButton" runat="server" OnClick="DocumentUploadButton_Click"
Text="Upload" Height="21px" Width="80px" /></td>
</tr>
<tr><td><asp:CustomValidator ID="DocumentUploadedCustomValidator" runat="server" Display="Dynamic" CssClass="labeltext"
ErrorMessage="<"Document must be uploaded %>"
OnServerValidate="DocumentUploadedCustomValidator_ServerValidate" ></asp:CustomValidator>
<asp:RegularExpressionValidator ID="DocumentUploadExpressionValidator" runat="server" CssClass="labeltext"
ControlToValidate="DocumentFileUpload" Display="Dynamic"
ErrorMessage="<"Only PDF or Word files is allowed."%>"
ValidationExpression="[a-zA-Z\\].*(.doc|.DOC|.docx|.DOCX|.pdf|.PDF)$"></asp:RegularExpressionValidator>

</td>
</tr>



protected void DocumentUploadedCustomValidator_ServerValidate(object source, ServerValidateEventArgs args)
{
CustomValidator cv = (CustomValidator)source;
args.IsValid = !String.IsNullOrEmpty(System.Convert.ToString(ViewState["DocumentFileId"]));

}

protected void DocumentUploadButton_Click(object sender, EventArgs e)
{
PDFFilename = Path.GetFileName(DocumentFileUpload.PostedFile.FileName);
int FileExtensionIndex = PDFFilename.IndexOf(".");
PDFFilename = PDFFilename.Substring(0, FileExtensionIndex);
PDFFilename += ".pdf";
ViewState["PDFFilename"] = PDFFilename;
Guid g = AddFile(DocumentFileUpload.FileBytes, PDFFilename);
File.Delete(PDFSaveLocation);
ViewState["DocumentFileId"] = g;
DocumentUploadedCustomValidator.IsValid = true;

if (ViewState["DocumentFileId"] != null)
{
DocumentUploadedLabel.CssClass = "SuccessMessagesLabel";
DocumentUploadedLabel.Text = "Document Uploaded Successfully";
}
else
{
DocumentUploadedLabel.CssClass = "ErrorMessagesLabel";
DocumentUploadedLabel.Text = "Document Upload Failed";
}}


Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.

AnswerRe: Validating File Upload Control with Regular Expression Validator Pin
Kevin Heathfield9-Jul-09 3:09
Kevin Heathfield9-Jul-09 3:09 
QuestionHow to specify Numeric Format i.e Numeric part and decimal part? Pin
ansriharsha8-Jul-09 23:35
ansriharsha8-Jul-09 23:35 
AnswerRe: How to specify Numeric Format i.e Numeric part and decimal part? Pin
Manas Bhardwaj8-Jul-09 23:56
professionalManas Bhardwaj8-Jul-09 23:56 
GeneralRe: How to specify Numeric Format i.e Numeric part and decimal part? Pin
ansriharsha9-Jul-09 2:30
ansriharsha9-Jul-09 2:30 
AnswerRe: How to specify Numeric Format i.e Numeric part and decimal part? Pin
Sun Rays9-Jul-09 3:44
Sun Rays9-Jul-09 3:44 
GeneralRe: How to specify Numeric Format i.e Numeric part and decimal part? Pin
ansriharsha9-Jul-09 3:55
ansriharsha9-Jul-09 3:55 
GeneralRe: How to specify Numeric Format i.e Numeric part and decimal part? Pin
ansriharsha17-Jul-09 0:46
ansriharsha17-Jul-09 0:46 
QuestionUser Defined Ajax Based Callback Control. Pin
vijay kharde8-Jul-09 23:11
vijay kharde8-Jul-09 23:11 
Questionsql server 2005 remote connection not allowed Pin
yogesh_kumar_agarwal8-Jul-09 22:51
yogesh_kumar_agarwal8-Jul-09 22:51 
AnswerRe: sql server 2005 remote connection not allowed Pin
Abhijit Jana8-Jul-09 23:58
professionalAbhijit Jana8-Jul-09 23:58 
GeneralRe: sql server 2005 remote connection not allowed Pin
yogesh_kumar_agarwal9-Jul-09 0:19
yogesh_kumar_agarwal9-Jul-09 0:19 
AnswerRe: sql server 2005 remote connection not allowed Pin
Sun Rays9-Jul-09 3:46
Sun Rays9-Jul-09 3:46 
QuestionSearch a file in a directory Pin
souravghosh188-Jul-09 22:48
souravghosh188-Jul-09 22:48 
AnswerRe: Search a file in a directory Pin
K03068-Jul-09 23:39
K03068-Jul-09 23:39 
Questionupdate gridview column Pin
vikas shukla8-Jul-09 22:47
vikas shukla8-Jul-09 22:47 
AnswerRe: update gridview column Pin
padmanabhan N8-Jul-09 22:57
padmanabhan N8-Jul-09 22:57 
AnswerRe: update gridview column Pin
Vimalsoft(Pty) Ltd8-Jul-09 23:38
professionalVimalsoft(Pty) Ltd8-Jul-09 23:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.