Click here to Skip to main content
15,905,028 members
Home / Discussions / C#
   

C#

 
AnswerRe: form close Pin
mpastchenko26-Aug-05 14:22
mpastchenko26-Aug-05 14:22 
GeneralRe: form close Pin
mpastchenko16-Sep-05 12:27
mpastchenko16-Sep-05 12:27 
Questionc# procedure Pin
Jassim Rahma26-Aug-05 10:39
Jassim Rahma26-Aug-05 10:39 
AnswerRe: c# procedure Pin
Colin Angus Mackay26-Aug-05 11:24
Colin Angus Mackay26-Aug-05 11:24 
GeneralRe: c# procedure Pin
Jassim Rahma26-Aug-05 12:52
Jassim Rahma26-Aug-05 12:52 
GeneralRe: c# procedure Pin
Dave Kreskowiak26-Aug-05 14:20
mveDave Kreskowiak26-Aug-05 14:20 
GeneralRe: c# procedure Pin
Jassim Rahma26-Aug-05 20:48
Jassim Rahma26-Aug-05 20:48 
GeneralRe: c# procedure Pin
Dave Kreskowiak27-Aug-05 2:59
mveDave Kreskowiak27-Aug-05 2:59 
GeneralRe: c# procedure Pin
Jassim Rahma27-Aug-05 3:38
Jassim Rahma27-Aug-05 3:38 
GeneralRe: c# procedure Pin
Dave Kreskowiak27-Aug-05 8:16
mveDave Kreskowiak27-Aug-05 8:16 
GeneralRe: c# procedure Pin
Jassim Rahma27-Aug-05 8:44
Jassim Rahma27-Aug-05 8:44 
GeneralRe: c# procedure Pin
Dave Kreskowiak28-Aug-05 3:18
mveDave Kreskowiak28-Aug-05 3:18 
GeneralRe: c# procedure Pin
Jassim Rahma28-Aug-05 8:30
Jassim Rahma28-Aug-05 8:30 
GeneralRe: c# procedure Pin
Dave Kreskowiak28-Aug-05 9:36
mveDave Kreskowiak28-Aug-05 9:36 
GeneralRe: c# procedure Pin
Jassim Rahma28-Aug-05 9:48
Jassim Rahma28-Aug-05 9:48 
GeneralRe: c# procedure Pin
Dave Kreskowiak29-Aug-05 1:24
mveDave Kreskowiak29-Aug-05 1:24 
QuestionScrolling TreeView without scrollbars shown. Pin
Blazej Stompel26-Aug-05 9:44
Blazej Stompel26-Aug-05 9:44 
AnswerRe: Scrolling TreeView without scrollbars shown. Pin
Dave Kreskowiak26-Aug-05 14:17
mveDave Kreskowiak26-Aug-05 14:17 
QuestionMSDE 2000 over network Pin
Anonymous26-Aug-05 9:27
Anonymous26-Aug-05 9:27 
AnswerI'm not really anonymous Pin
theStorminMormon26-Aug-05 9:30
theStorminMormon26-Aug-05 9:30 
GeneralRe: I'm not really anonymous Pin
Alomgir Miah26-Aug-05 18:23
Alomgir Miah26-Aug-05 18:23 
QuestionCircle Image Pin
nc3b26-Aug-05 9:18
nc3b26-Aug-05 9:18 
QuestionForce user to submit excel file Pin
t2126-Aug-05 8:00
t2126-Aug-05 8:00 
OVERVIEW: When a user browses for a file it can choose and file extension. I want to limit this. So that if they choose say a jpg file it will say: " Sorry wrong ext. please submit an .xls file." I want to force the user to submit an excel file only. Any Clue will be help full.
I posted my code below.
Thank in advance



public class WebForm2 : System.Web.UI.Page
{
protected System.Web.UI.HtmlControls.HtmlInputFile inpFile;//Browse file
protected System.Web.UI.WebControls.Image imgPAIS;//PAIS image
protected System.Web.UI.HtmlControls.HtmlInputButton btnSubmit;//Submit button



private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent(); //Calls the sub-procedure

base.OnInit(e);
}

///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.btnSubmit.ServerClick += new System.EventHandler(this.btnSubmit_ServerClick); //when btnSubmit Clicked
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion


private void btnSubmit_ServerClick(object sender, System.EventArgs e)// When btnSubmit Click follow sub-procedure
{


if( ( inpFile.PostedFile != null ) && ( inpFile.PostedFile.ContentLength > 0 ) )
{

string fn = System.IO.Path.GetFileName(inpFile.PostedFile.FileName);

//string procID = DateTime.Now.ToString("MMddHHmm");
string SaveLocation = Server.MapPath("Data") + "\\" + fn; //+ "NewUsers." + procID;//+ ".xls";


try
{
inpFile.PostedFile.SaveAs(SaveLocation);
Response.Write("Your file has been successfully submitted."); //Reads when file is done submitting
}
catch ( Exception ex )//If no file read
{

Response.Write("Error: " + ex.Message);
}
}
else
{

Response.Write("Please select a file to submit."); //Reads when no file selected
}
}
}
}
AnswerRe: Force user to submit excel file Pin
Daniel Turini26-Aug-05 9:04
Daniel Turini26-Aug-05 9:04 
GeneralRe: Force user to submit excel file Pin
t2126-Aug-05 11:15
t2126-Aug-05 11:15 

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.