hgh.just.hony
چهارشنبه 28 تیر 1391, 12:10 عصر
سلام
این کده منه
کجای این کد می تونم از image loader استفاده کنم؟
<%@ Page Language="C#" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script src="jquery-1.6.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_ pageLoaded(pageLoaded);
//Handle the pageLoaded event. The below function will execute on every
//UpdatePanel' update.
function pageLoaded(sender, args)
{
$("#pvwImage").attr("src", imageSrc);
}
</script>
<script runat="server">
string filename;
string file_name;
Guid gi ;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void UploadButton_Click(object sender, EventArgs e)
{
//if (FileUpload1.HasFile && FileUpload1.FileBytes.Length < 30000 &&
// !CheckForFileName())
//{
//string savePath = Request.PhysicalApplicationPath + saveDir +
//Server.HtmlEncode(FileName.Text);
//Remove comment from the next line to upload file.
//string savePath = "e:\\1";
//FileUpload1.SaveAs(@"e:\1\");
//FileUpload1.SaveAs("e:\\1\\1.jpg");
// UploadStatusLabel.Text = "The file was processed successfully.";
//}
//else
//{
// UploadStatusLabel.Text = "You did not specify a file to upload, or a file name, or the file was too large. Please try again.";
//}
}
protected void UploadButton1_Click(object sender, EventArgs e)
{
Image1.ImageUrl = file_name;
System.Threading.Thread.Sleep(30);
UpdatePanel1.Update();
}
//protected void CheckButton_Click(object sender, EventArgs e)
//{
// if (FileName.Text.Length > 0)
// {
// string s = CheckForFileName() ? "exists already." : "does not exist.";
// UploadStatusLabel.Text = "The file name choosen " + s;
// }
// else
// {
// UploadStatusLabel.Text = "Specify a file name to check.";
// }
//}
//private Boolean CheckForFileName()
//{
// System.IO.FileInfo fi = new System.IO.FileInfo(Request.PhysicalApplicationPath +
// saveDir + Server.HtmlEncode(FileName.Text));
// return fi.Exists;
//}
protected void AsyncFileUpload1_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
{
if (AsyncFileUpload1.HasFile)
{
string type = AsyncFileUpload1.ContentType;
if (type.Contains("bmp") | type.Contains("png") | type.Contains("jpeg"))
{
file_name = AsyncFileUpload1.FileName;
//filename = Server.MapPath("") + "/" +AsyncFileUpload1.FileName;
gi = new Guid();
filename = Server.MapPath("") + "/" + gi.ToString() + ".jpg";
file_name = gi.ToString() + ".jpg";
AsyncFileUpload1.SaveAs(filename);
System.IO.FileInfo f = new System.IO.FileInfo(Server.MapPath("") + "/" + file_name);
if (f.Length > 30720)
{
Response.Write("alert('big size..... just less than 30kb');");
System.IO.File.Delete(Server.MapPath("") + "/" + file_name);
}
else
UploadButton1_Click(new object(), new EventArgs());
}
else
return;
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>PostBackTrigger Example</title>
</head>
<body>
<form id="form2" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
The upload button is defined as a PostBackTrigger.<br/>
<div style="width: 220px;display:none; height: 60px; text-align: center; vertical-align: middle;
background-color: White; border: double 5px Gray; position: relative; top: 200px;
padding-top: 10px;">
<div>
Loading ... Please wait ...</div>
<div style="padding-top: 10px;">
<img src="black-019-loading-p.gif" alt="Loading ... " /></div>
</div>
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<fieldset>
<legend>FileUpload in an UpdatePanel</legend>
First, enter a file name to upload your file to:
<asp:FileUpload id="FileUpload1"
runat="server">
</asp:FileUpload>
<br />
<asp:AsyncFileUpload ID="AsyncFileUpload1" runat="server"
onuploadedcomplete="AsyncFileUpload1_UploadedComplete"
PersistFile="True"
/>
<asp:Image ID="Image1" runat="server" />
<br />
<input id="Button1" type="button" value="upload" OnClick="UploadButton1_Click" onkeypress="document.getElementbyId('preLoad').style. display = block;" />
<%--<asp:Button id="UploadButton"
Text="Upload file"
OnClick="UploadButton_Click"
runat="server">--%>
</asp:Button>
<asp:Button ID="Button1" runat="server"
Text="123e" />
<br />
<br />
<br />
<asp:Label id="UploadStatusLabel"
runat="server" style="color:red;">
</asp:Label>
</fieldset>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="AsyncFileUpload1" />
<asp:PostBackTrigger ControlID="Button1" />
</Triggers>
</asp:UpdatePanel>
</div>
<br />
<asp:TextBox ID="TextBox1" runat="server" Height="104px" TextMode="MultiLine"
Width="592px"></asp:TextBox>
</form>
</body>
</html>
گذاشتما اما اصلا کار نکرد
میخام هرجایی که دوست دارم مثلا گرید یا پنل یا دکمه یا ... از image loader استفاده کنم
میشه کمک کنین.
من مبتدی هستم:خجالت::خجالت::قلب::قلب:: امزه::افسرده:
این کده منه
کجای این کد می تونم از image loader استفاده کنم؟
<%@ Page Language="C#" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script src="jquery-1.6.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_ pageLoaded(pageLoaded);
//Handle the pageLoaded event. The below function will execute on every
//UpdatePanel' update.
function pageLoaded(sender, args)
{
$("#pvwImage").attr("src", imageSrc);
}
</script>
<script runat="server">
string filename;
string file_name;
Guid gi ;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void UploadButton_Click(object sender, EventArgs e)
{
//if (FileUpload1.HasFile && FileUpload1.FileBytes.Length < 30000 &&
// !CheckForFileName())
//{
//string savePath = Request.PhysicalApplicationPath + saveDir +
//Server.HtmlEncode(FileName.Text);
//Remove comment from the next line to upload file.
//string savePath = "e:\\1";
//FileUpload1.SaveAs(@"e:\1\");
//FileUpload1.SaveAs("e:\\1\\1.jpg");
// UploadStatusLabel.Text = "The file was processed successfully.";
//}
//else
//{
// UploadStatusLabel.Text = "You did not specify a file to upload, or a file name, or the file was too large. Please try again.";
//}
}
protected void UploadButton1_Click(object sender, EventArgs e)
{
Image1.ImageUrl = file_name;
System.Threading.Thread.Sleep(30);
UpdatePanel1.Update();
}
//protected void CheckButton_Click(object sender, EventArgs e)
//{
// if (FileName.Text.Length > 0)
// {
// string s = CheckForFileName() ? "exists already." : "does not exist.";
// UploadStatusLabel.Text = "The file name choosen " + s;
// }
// else
// {
// UploadStatusLabel.Text = "Specify a file name to check.";
// }
//}
//private Boolean CheckForFileName()
//{
// System.IO.FileInfo fi = new System.IO.FileInfo(Request.PhysicalApplicationPath +
// saveDir + Server.HtmlEncode(FileName.Text));
// return fi.Exists;
//}
protected void AsyncFileUpload1_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
{
if (AsyncFileUpload1.HasFile)
{
string type = AsyncFileUpload1.ContentType;
if (type.Contains("bmp") | type.Contains("png") | type.Contains("jpeg"))
{
file_name = AsyncFileUpload1.FileName;
//filename = Server.MapPath("") + "/" +AsyncFileUpload1.FileName;
gi = new Guid();
filename = Server.MapPath("") + "/" + gi.ToString() + ".jpg";
file_name = gi.ToString() + ".jpg";
AsyncFileUpload1.SaveAs(filename);
System.IO.FileInfo f = new System.IO.FileInfo(Server.MapPath("") + "/" + file_name);
if (f.Length > 30720)
{
Response.Write("alert('big size..... just less than 30kb');");
System.IO.File.Delete(Server.MapPath("") + "/" + file_name);
}
else
UploadButton1_Click(new object(), new EventArgs());
}
else
return;
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>PostBackTrigger Example</title>
</head>
<body>
<form id="form2" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
The upload button is defined as a PostBackTrigger.<br/>
<div style="width: 220px;display:none; height: 60px; text-align: center; vertical-align: middle;
background-color: White; border: double 5px Gray; position: relative; top: 200px;
padding-top: 10px;">
<div>
Loading ... Please wait ...</div>
<div style="padding-top: 10px;">
<img src="black-019-loading-p.gif" alt="Loading ... " /></div>
</div>
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<fieldset>
<legend>FileUpload in an UpdatePanel</legend>
First, enter a file name to upload your file to:
<asp:FileUpload id="FileUpload1"
runat="server">
</asp:FileUpload>
<br />
<asp:AsyncFileUpload ID="AsyncFileUpload1" runat="server"
onuploadedcomplete="AsyncFileUpload1_UploadedComplete"
PersistFile="True"
/>
<asp:Image ID="Image1" runat="server" />
<br />
<input id="Button1" type="button" value="upload" OnClick="UploadButton1_Click" onkeypress="document.getElementbyId('preLoad').style. display = block;" />
<%--<asp:Button id="UploadButton"
Text="Upload file"
OnClick="UploadButton_Click"
runat="server">--%>
</asp:Button>
<asp:Button ID="Button1" runat="server"
Text="123e" />
<br />
<br />
<br />
<asp:Label id="UploadStatusLabel"
runat="server" style="color:red;">
</asp:Label>
</fieldset>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="AsyncFileUpload1" />
<asp:PostBackTrigger ControlID="Button1" />
</Triggers>
</asp:UpdatePanel>
</div>
<br />
<asp:TextBox ID="TextBox1" runat="server" Height="104px" TextMode="MultiLine"
Width="592px"></asp:TextBox>
</form>
</body>
</html>
گذاشتما اما اصلا کار نکرد
میخام هرجایی که دوست دارم مثلا گرید یا پنل یا دکمه یا ... از image loader استفاده کنم
میشه کمک کنین.
من مبتدی هستم:خجالت::خجالت::قلب::قلب:: امزه::افسرده: