|
hi,dear
iam working on uploading image from contentPage of asp.net ..its working fine when iam using a normal webpage...when iam giving in tag of normal webpage the code:
<form id="form1" enctype="multipart/form-data" runat="server">
</form>
its works fine i can upload my image ,but using ContentPage when iam not using this form tag here,but only at MasterPage..iam not getting image content in my Upload control..
>>>>iam using Controls in my ContentPage are:
1.input(file) HTML Control named filUpload
2.webButtonControl named btnUpload.
plz help me out...thanx in advance
Here is my MasterPage code part
<body>
<form id="form1" enctype="multipart/form-data" runat="server">
<asp:scriptmanager runat="server" id="scrpt1" xmlns:asp="#unknown" />
<div>
</div></form></body>
ContentPage...Default3.aspx.cs
protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
this.Page.ClientScript.RegisterForEventValidation(btnUpload.ID);
}
protected void btnUpload_Click(object sender, System.EventArgs e)
{
string sSavePath;
string sThumbExtension;
int intThumbWidth;
int intThumbHeight;
sSavePath = "images/";
sThumbExtension = "_thumb";
intThumbWidth = 160;
intThumbHeight = 120;
if (filUpload.PostedFile != null) ...
{
HttpPostedFile myFile = filUpload.PostedFile;
int nFileLen = myFile.ContentLength;
if (nFileLen == 0)
{
lblOutput.Text = "No file was uploaded.";
return;
}
if (System.IO.Path.GetExtension(myFile.FileName).ToLower() != ".jpg")
{
lblOutput.Text = "The file must have an extension of JPG";
return;
}
byte[] myData = new Byte[nFileLen];
myFile.InputStream.Read(myData,0,nFileLen);
string sFilename = System.IO.Path.GetFileName(myFile.FileName);
int file_append = 0;
while (System.IO.File.Exists(Server.MapPath(sSavePath + sFilename)))
{
file_append++;
sFilename = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName)
+ file_append.ToString() + ".jpg";
}
System.IO.FileStream newFile
= new System.IO.FileStream(Server.MapPath(sSavePath + sFilename),
System.IO.FileMode.Create);
newFile.Write(myData,0, myData.Length);
newFile.Close();
System.Drawing.Image.GetThumbnailImageAbort myCallBack =
new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
Bitmap myBitmap;
try
{
myBitmap = new Bitmap(Server.MapPath(sSavePath + sFilename));
file_append = 0;
string sThumbFile = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName)
+ sThumbExtension + ".jpg";
while (System.IO.File.Exists(Server.MapPath(sSavePath + sThumbFile)))
{
file_append++;
sThumbFile = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName) +
file_append.ToString() + sThumbExtension + ".jpg";
}
System.Drawing.Image myThumbnail
= myBitmap.GetThumbnailImage(intThumbWidth,
intThumbHeight, myCallBack, IntPtr.Zero);
myThumbnail.Save (Server.MapPath(sSavePath + sThumbFile));
imgPicture.ImageUrl = sSavePath + sThumbFile;
lblOutput.Text = "File uploaded successfully!";
myThumbnail.Dispose();
myBitmap.Dispose();
}
catch (ArgumentException errArgument)
{
lblOutput.Text = "The file wasn't a valid jpg file.";
System.IO.File.Delete(Server.MapPath(sSavePath + sFilename));
}
}
}
public bool ThumbnailCallback()
{
return false;
}
}
|
|
|
|
|
premprakashbhati wrote: but using ContentPage when iam not using this form tag here,but only at MasterPage..i
Content Page should not have any Form Tag. All the controls should be in asp:content tages.
premprakashbhati wrote: am not getting image content in my Upload control..
>>>>iam using Controls in my ContentPage are:
1.input(file) HTML Control named filUpload
2.webButtonControl named btnUpload.
I believe you are using this in Content Page . You are having a FileUpload control and Having a Asp Button. and you have given the code of button click. Then what is your problem ?
premprakashbhati wrote: iam not getting image content in my Upload control..
What does it mean ?
cheers,
Abhijit
|
|
|
|
|
hi ,abhijeet...
my problem is when iam uploading the image file by clicking browse button of filUpload --input(file)HTMLControl,and clicked on Upload webControl button..iam not getting the image file in filUpload control..(Here iam Working with Master and ContentPage)
>>i have tested this by taking one asp.net page and provided in tag that
<form id="form1" enctype="multipart/form-data" runat=server>
and in aspx.cs page the provided .cs code..its working fine means iam getting the image file in filUpload Control and i can upload it to the image control on my .aspx in thumbnail form and storing the same image file in images application folder .
modified on Friday, December 26, 2008 5:31 AM
|
|
|
|
|
plz see to it ..
no answer from anyone............
|
|
|
|
|
|
Dear,
I using GridView in ASP.NET
it can show size paging, and work normally (data changed when click move page), but when I use code below to change row, it does not work (data not changed)
foreach (GridViewRow gvr in rst_Table.Rows)
{
gvr.Cells[0].Text = "" + i.ToString() + ".";
gvr.Cells[5].Text = CommonUtils._gender(ds.Tables[0].Rows[i -1]["Gender"].ToString());
i += 1;
}
Please help me
Socheat
|
|
|
|
|
Socheat.Net wrote: ut when I use code below to change row, it does not work (data not changed)
What's error are you getting ?
cheers,
Abhijit
|
|
|
|
|
I did not get error, but data that display still the same in first page
Socheat
|
|
|
|
|
Debug the code,Is the function is called where you have written the above code.
Cheers!!
Brij
|
|
|
|
|
Where you have written this code?
Cheers!!
Brij
|
|
|
|
|
hi
Could anyone tell me how can I include a chat in my asp.net2005(C#) web application(chat like gmail chat) its like a one to one chat, new messages shown in a pop windows. Anyone give me some sample code....
otherwise send some links related to this...
Regards
mohan
|
|
|
|
|
|
i have a project in asp.net 2003, when i open it in 2005 am getting following error message:
" IT IS AN ERROR TO USE A SECTION REGISTERED AS ALLOWDEFINITION ='MACHINETOAPPLICATION BEYOND APPLICATION LEVEL. THIS ERROR CAN BE CAUSED BY AVIRTUAL DIRECTORYNOT BEING CONFIGURES AS AN APPLICATION IN IIS"
am not much aware about this kind of errors. could any one clear my doubt...
self confidence+hard work=SUCCESS
|
|
|
|
|
Are you trying to open the Web sites from where ?
just open from VS 2005, it will automatically do needful.
cheers,
Abhijit
|
|
|
|
|
yeah abhijit am trying to open from 2005 only, when i built the appliaction i throws the exception i mentioned....
self confidence+hard work=SUCCESS
|
|
|
|
|
where is your web.config file ? is it in the root or Subdirectory ? ?It should be in Root Directory.
Any way I have just goggled, its gives[^]
Let me know if its resolved !
cheers,
Abhijit
|
|
|
|
|
Hi Abhijit,
i found that, here with my application there are two web.config files,, when framework ask to take back up ,there is a web.config file in that folder too, so only this problem, i remove that and now my site is running ..
thanks man...
self confidence+hard work=SUCCESS
|
|
|
|
|
Yup... Great !!!
cheers,
Abhijit
|
|
|
|
|
Hi, I have a question with respect to the security implementation of Menu
using sitemap. Normally in the sitemap we can implement role based security
but that is based on the Role based functionality provided by ASP.NET.
Actually in our site we are using custom roles with our own role management
and stuff. So is there a way to hide or show certain elements of the Sitemap
in my menu based on the custom roles without using asp.net roles
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
hi,
I am doing a Project (in ASP.NET using C# ) in which i have to display a Message Box ,after clicking on a button .I have used a MesterPage and i want a javascript message Box .I mean in the following case:
button_Save_click()
{
.....Other code ...
//after completion of above code,Message should be displayed..
message("Data is Saved...");
}
i Want all these in Java Script(and asp.net using C#). Also it should be as simple as possibe,and as soon as possible.
also a confirmation box in which after clicking on Delete button,It should ask "do u want to delete" if yes do this...else do this...
Please do help me..soon
expecting early reply of anbody..
|
|
|
|
|
For javascript message box ,Do as following
Register the javascript code as below in the button_Save_click() function after saving the data(i e last line in thios function)
string strMsg="data Saved";
Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowMessage", "alert('" + strMsg+ "');", true);
For confirmation box
You use confirm instead of alert and if its true then delete else not as
<input id="btnSave" style="display:none" type="Button" value="Save" onclick="javascript:var blnValid = SaveDataAfterValidation(); if(!blnValid){return;}" onserverclick="SaveData_Click" runat="server"/>
Here SaveDataAfterValidation(); is a javascipt function showing the confirmbox
Cheers!!
Brij
|
|
|
|
|
hi, Thanks for the reply.
as per u say i have tried the below code for a message:
string strMsg="data Saved";
Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowMessage", "alert('" + strMsg+ "');", true);
Although the above code display a messaagebox but still the background page does not display, instead it displays only a blank and new page,then a message box display.
I mean a message box should be displayed on the same page from where it is called.
wating for the positive response.
|
|
|
|
|
I think you must be doing something wrong.Ahter this,the messagebox will be displayed ,when you click on ok then the page will be loaded.If some another page is coming.Check it with URL, for the page name.
And tell me where you have written this piece of code?
Can you write step by step,what you have done on the page for this functionality?
Cheers!!
Brij
|
|
|
|
|
refer following link
[^]
this will help u for Javascript CONFIRM
regards
koolprasad2003
If the message is useful for U then please Rate This message...
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
hi,
I am doing a Project "Message Board" in ASP.NET using C#. I have to display sticky post first. i Mean how to sort so that sticky post should be displayed first..I mean the topics or post which are posted by a person 10 or more than times.
If posts are 10 or more than 10 then should be displayed first in the data grid as well as sorting should be as per the last modified also.
how will it be possible.
please send me a simple code.. or query
|
|
|
|