Current location: Hot Scripts Forums » Programming Languages » Windows .NET Programming » Error message not getting displayed.

Error message not getting displayed.

 
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 12-20-05, 11:48 AM
sanjeet sanjeet is offline
New Member
 
Join Date: Dec 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Error message not getting displayed.

OK What I am trying to do is display the message in my custom validator that a file was not selected only if the user select an update button with out selecting the file.

This is what's happening:

1. Curently the update link can add a new file or modify an existing file. view state is used to see if a file already exists or not:

private int _fileId
{
get
{
if ( ViewState[ "FileId" ] != null )
return Convert.ToInt32( ViewState[ "FileId" ] );
else
return 0;
}
set { ViewState[ "FileId"] = value; }
}


2. When the user clicks the file update button this is what gets processed.:

private void Update_Click(object sender, System.EventArgs e)
{

OnlineCaseFileInfo file = new OnlineCaseFileInfo();
OnlineCaseFileController controller = new OnlineCaseFileController();

file.CaseId = _caseId;
file.FileDescription = FileDescription.Text;

// New File Browse button visible for editing a file
HttpPostedFile pFile = NewFileName.PostedFile;
byte[] fileData = new byte[pFile.ContentLength];
pFile.InputStream.Read( fileData, 0, pFile.ContentLength );
file.FileId = FileHandler.SaveFile( _caseId, fileData, pFile.FileName );
file.FileName = FileHandler.GetShortFileName( pFile.FileName );

if (!Page.IsValid) // Now this code will call the validate function
return;




if ( _fileId == 0 )



{
// Add file if file id is 0
controller.Add( file );
}

else // update file if file exists

{

file.FileId = _fileId;
controller.Update( file );

}

controller = null;


3. This function gets called:


public void WrongeFileUpdate_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
{
// Display wrong file message if not correct file is selected

if ( _fileId != 0 )
{
//Make sure the file name is from the correct path, only file name should be compared
_filename = FileHandler.GetShortFileName(_filename); //FileHandler GetShortFile name retreives only the file name
// New File Browse button visible for editing a file
OnlineCaseFileInfo file = new OnlineCaseFileInfo();
OnlineCaseFileController controller = new OnlineCaseFileController();



file.CaseId = _caseId;
file.FileDescription = FileDescription.Text;


// New File Browse button visible for editing a file
HttpPostedFile pFile = NewFileName.PostedFile;
byte[] fileData = new byte[pFile.ContentLength];
pFile.InputStream.Read( fileData, 0, pFile.ContentLength );
file.FileId = FileHandler.SaveFile( _caseId, fileData, pFile.FileName );
file.FileName = FileHandler.GetShortFileName( pFile.FileName );

string newfilename = file.FileName = FileHandler.GetShortFileName( pFile.FileName );
newfilename = FileHandler.GetShortFileName(newfilename);

if( _filename != newfilename )

{

WrongeFileUpdate.Text = "Wrong File Being Updated";
args.IsValid = false;
}

}

if ( _fileId == 0)
{
if (this.NewFileName.Value == "")
{
WrongeFileUpdate.Text = "No File Selected. Please select a file."; // So the code does reach here when I step through it.
args.IsValid = false;
}
}

4. However after it finishes executing this function. It displays this error message:

A critical error has occurred.
Could not find a part of the path "C:\DNNmyAANS\Portals\0\onlinecase\5\".
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Current Exchange Rate Displayed on my site p17blo The Lounge 0 02-03-05 07:12 AM
Only the first word is displayed in the form when editing. jozin PHP 5 11-07-04 02:18 AM
Upload file to table so ONLY files tied to primary key are displayed in record? grafixDummy PHP 4 12-20-03 05:28 PM
Images not displayed SmartBiz PHP 2 11-03-03 03:50 PM
Can download status be displayed... wrhodesjr JavaScript 0 10-27-03 02:12 PM


All times are GMT -5. The time now is 11:31 AM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.