|
But FileUpload class is present only in .NET 2.0 whereas I am using 1.1 version for my whole project. Plz tell me the method to do it in .NET 1.1 framework
Thanks,
Sandy
|
|
|
|
|
Try the below code,It is working in .Net 1.1
//uploading files control
System.Web.UI.HtmlControls.HtmlInputFile ctlImageInput;
//Declarations
string strFileName;
string strFilePath;
string strFolder;
//u can use the unique user name for all the folders
strFolder = AppDomain.CurrentDomain.BaseDirectory + "Images/username";
// Creating Directory
if ((!(Directory.Exists(strFolder))))
{
Directory.CreateDirectory(strFolder);
}
//Saving source file to destination
if( ctlImageInput.Value !="")
{
strFileName = ctlImageInput.PostedFile.FileName;
strFileName = Path.GetFileName(strFileName);
strFilePath = strFolder + "/"+ strFileName;
ctlImageInput.PostedFile.SaveAs(strFilePath);
}
|
|
|
|
|
But I don't have .NET 2.0 and I want to bring the file from client's computer to my server.
Whenever I use the above code , it says object reference not set to an instance of an object. In Html code I had taken,
Thanks,
Sandy
|
|
|
|
|
public class Uploadphoto : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label Label1;
string strPath;
private void Page_Load(object sender, System.EventArgs e)
{
long ID = 8;
// long PropertyID = long.Parse(Request.QueryString["id"]);
string appPath = Server.MapPath("Photos");
strPath = appPath + "\\" + ID.ToString();
System.IO.Directory.CreateDirectory(strPath);
}
#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();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
string strFile = Request.Form["inpFile"].ToString();
string strFileName = strFile.Substring(strFile.LastIndexOf("\\")+1,strFile.Length-(strFile.LastIndexOf("\\")+1));
File.Copy(Request.Form["inpFile"],strPath + "\\" + strFileName);
}
}
and my HTML code is
<HTML>
<HEAD>
<title>Uploadphoto</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Label id="Label1" style="Z-INDEX: 102; LEFT: 110px; POSITION: absolute; TOP: 57px" runat="server"
ForeColor="Red" Visible="False">You can only add files with .jpg,.gif or .bmp extensions</asp:Label>
<asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 378px; POSITION: absolute; TOP: 127px" runat="server"
Text="Upload"></asp:Button><INPUT style="Z-INDEX: 104; LEFT: 107px; POSITION: absolute; TOP: 128px" type="file" id="inpFile"
name="inpFile">
</form>
</body>
</HTML>
The problem is that when I click the Upload button after browsing and selecting a file in FileInput control, I get the following exception
Exception Details: System.IO.FileNotFoundException: Could not find file "C:\Documents and Settings\Sandy\Desktop\cities.txt".
Source Error:
Line 66: string strFile = Request.Form["inpFile"].ToString();
Line 67: string strFileName = strFile.Substring(strFile.LastIndexOf("\\")+1,strFile.Length-(strFile.LastIndexOf("\\")+1));
Line 68: File.Copy(Request.Form["inpFile"],strPath + "\\" + strFileName);
plz help me. I want to upload the file from client machine to my server
Thanks,
Sandy
|
|
|
|
|
The earlier code will work to complete ur requirement
Declare a control as server control by below code
Now try..
-- modified at 8:35 Tuesday 25th April, 2006
|
|
|
|
|
Failed to open a rowset.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: CrystalDecisions.CrystalReports.Engine.InternalException: Failed to open a rowset.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InternalException: Failed to open a rowset.]
[1].[1]K(String
, EngineExceptionErrorID
) +642
[1].[1]F(Int16 [1], Int32
--------------------------------------------------------------------------------
) +491
CrystalDecisions.CrystalReports.Engine.FormatEngine.GetLastPageNumber(ReportPageRequestContext reqContext) +187
CrystalDecisions.ReportSource.LocalReportSourceBase.GetLastPageNumber(ReportPageRequestContext reqContext) +174
CrystalDecisions.Web.ReportAgent.get_LastPageNumber() +34
CrystalDecisions.Web.ReportAgent.v(Boolean
--------------------------------------------------------------------------------
`) +90
CrystalDecisions.Web.CrystalReportViewer.OnPreRender(EventArgs e) +108
System.Web.UI.Control.PreRenderRecursiveInternal() +62
System.Web.UI.Control.PreRenderRecursiveInternal() +125
System.Web.UI.Control.PreRenderRecursiveInternal() +125
System.Web.UI.Page.ProcessRequestMain() +1499
Sathisha B N
|
|
|
|
|
Hi Sathisha,
Did u assign the dataset to the data source property of the crystal report.Check if there are any rows in the table.If the table is empty or if the query results are empty there are chances of getting this error.
Uma
|
|
|
|
|
how to bind html dropdownbox control in design view and
in codeview ,
|
|
|
|
|
u need to use asp.net web controls for that and make them run at server. Only then u can bind them in the code view. Otherwise u have to write some javascript
to populate them.
Sandy Sekhon
|
|
|
|
|
Hi all,
I want to create db in sql server 2005. Just i have gone to object explorer and in the database folder. i just right click and said new database, then i got below this error. This is the way to create new database or anyother way. please help me anyone
TITLE: Microsoft SQL Server Management Studio
----------------------------------------
Cannot show requested dialog.
----------------------------------------
ADDITIONAL INFORMATION:
Full-text is not supported on this edition of SQL Server. (Microsoft.SqlServer.Smo)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft SQL Server&ProdVer=9.00.1116.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.UnsupportedFeatureException&LinkId=20476
----------------------------------------
BUTTONS:
OK
----------------------------------------
Regards,
siva
|
|
|
|
|
Please don't cross post - You already posted this in the SQL forum which is the appropriate place for this question - The ASP.NET forum is not the best place for this question.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
How to do popup panel control or any popup in which i want to display repeaters content
|
|
|
|
|
Hi... I want to send mail mail by using ASP. I have ip address and SMTP relay server address.. Please give me the code for Mail sending ....
Thanking you,
Bawa
|
|
|
|
|
You also need a mail component. Your web hotel most likely provides a common third party component that you can use. Then either the web hotel or the maker of the component have examples on how to use it.
---
b { font-weight: normal; }
|
|
|
|
|
hi Bawa,
hope this may help u
Dim objMail As New MailMessage()
objMail.From = "your_name@yourdomain.com"
objMail.To = Request.Form("Email")
objMail.Subject = Request.Form("Subject")
objMail.Body = Request.Form("Message")
objMail.BodyFormat = MailFormat.Text
SmtpMail.SmtpServer = " smtp.your-server.com"
SmtpMail.Send(objMail)
Sandy
|
|
|
|
|
Hi all
I have an doubt
Is it posible to ZIPing a file/folder by programetically
I mean to say with a program can't we ZIp a file
asdfasdfasdfasdfasdfasdfasdfasdfasdfasdf
|
|
|
|
|
|
Im trying to create a web application and I added a CreateUserWizard control. When I added this control and ran the application, I got this error (listed below) when I tried to open the page. I added a <form runat = "server"> tag and I got another error saying "A page can only have one server side form tag"
Can some one please help???
Server Error in '/University' Application.
--------------------------------------------------------------------------------
Control 'ctl00_Main_CreateUserWizard1' of type 'CreateUserWizard' must be placed inside a form tag with runat=server.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Control 'ctl00_Main_CreateUserWizard1' of type 'CreateUserWizard' must be placed inside a form tag with runat=server.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Control 'ctl00_Main_CreateUserWizard1' of type 'CreateUserWizard' must be placed inside a form tag with runat=server.]
System.Web.UI.Page.VerifyRenderingInServerForm(Control control) +301
System.Web.UI.WebControls.Wizard.Render(HtmlTextWriter writer) +54
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +74
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +291
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +49
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +234
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +53
System.Web.UI.Control.Render(HtmlTextWriter writer) +31
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +74
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +291
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +49
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +234
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +53
System.Web.UI.Control.Render(HtmlTextWriter writer) +31
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +74
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +291
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +49
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +234
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +53
System.Web.UI.Control.Render(HtmlTextWriter writer) +31
System.Web.UI.Page.Render(HtmlTextWriter writer) +39
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +74
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +291
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +49
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5539
|
|
|
|
|
Make sure that the wizard control is between the start and end tags of the form.
---
b { font-weight: normal; }
|
|
|
|
|
The wizard control was in between the start and end tags.
<asp:......>
I even tried
Thank you anyway but that did not solve my problem.
|
|
|
|
|
Then there has to be something wrong with your html, because it's not recognising the form correctly.
A minimum page should be:
<html>
<head>
<title></title>
</head>
<body>
<form runat="server">
... here goes your controls
</form>
</body>
</html>
<small>---
b { font-weight: normal; }</small>
|
|
|
|
|
Hi everyone,
Can we bring third party tools such as adobe photoshop in the browser,whatever be the methodology.I know it would be difficult to add the reference of that tool in an asp.net project since asp.net accepts only .net or com components.
But i have seen , some applications which bring external imaging tools in thier browser.How to do it.Can we do this with pure HTML?
I think,I had asked this question earlier.But ,Since i am not aware of the solution yet, I am posting the question again.
Any help would be appreciated.
Thank you
-- modified at 23:57 Monday 24th April, 2006
|
|
|
|
|
Hi everybody,
Please i know that this is really a stupide question in a furom but i really need if you can just tell me how can i start ASP.Net
i will study it but i think know it before is a good thing + the teacher won't give you all what you need so please if you can just tell me or give me a link of a good tutorial , course,anything can be good in this start
thank you very very much
try to be good if you can't be the best
|
|
|
|
|
Mohammed Amine wrote: i know that this is really a stupide question
I don't think it's a stupid question. Welcome to CodeProject !
Here are some good places that can get you started:
ASP.NEt quick start[^]
ASP.NET starter kits[^]
Also, when you get stuck on a specific issue, don't forget your best friend CodeProject (hopefully in the near future ).
|
|
|
|
|
thank you man i won't forget
try to be good if you can't be the best
|
|
|
|