asp.net 庶罩层上传图片(二进制),并显示二进制图片
1.上传功能
JS检查
function hideUpImg()//关闭层,并上传图片
{
var v=document.getElementById("upImg").value;
var after=v.substring(v.lastIndexOf('.')).toLowerCase();
alert(after);
if(v.length<=0)
{
alert("请选择图片");
return false;
}
if(after==".jpg"||after==".gif"||after==".png")
{
return true;
}
alert("图片只能是.jpg .gif .png格式");
document.getElementById("upImg").outerHTML=document.getElementById("upImg").outerHTML;
return false;
}
页面代码:
<div id="myDiv" style="display: none;" mce_style="display: none;" class="divshowbottom"> </div>
<div id="upLoadImg" style="top: 200px;left: 300px;display: none;" class="divshowwork">
<div style="width: 100%; height: 20px;background-color: #FF0000; cursor: move;">上传图片</div>
<p style="text-align: center;" mce_style="text-align: center;">请上传图片</p>
<asp:FileUpload ID="upImg" runat="server" />
<asp:Label ID="lblState" runat="server" ></asp:Label>
<br /><asp:Button ID="btnUpImg" runat="server" Text="上传" OnClick="btnUpImg_Click" /> <input type="button" value="取消" id="button_2" />
</div>
后台代码:
Stream stream = this.upImg.PostedFile.InputStream;
byte[] photo = new byte[upImg.PostedFile.ContentLength];
stream.Read(photo, 0, upImg.PostedFile.ContentLength);
ItemMaster im = new ItemMaster();
im.ItemUid =Convert.ToInt32(s.Split('|')[1]);
im.Drawing = photo;
int upd = ItemMasterBIZ.UpdItemMasterByImg(im);
stream.Cl
相关文档:
//private string datapatch = ConfigurationSettings.AppSettings["acessconn"];//数据库地址
private string datapatch = "db/global.asa";//数据库地址
///
/// 取得dataset
//
/// 查询语句
///
public DataSet GetDataSet(string Commandtext)
{&nbs ......
示例一
在Global.asax.cs文件中:
protected void Application_Start(Object sender, EventArgs e)
{
System.Timers.Timer timer1 = new System.Timers.Timer();
&nbs ......
The Model-View-Controller (MVC) architectural pattern separates an application into three main components: the model, the view, and the controller. The ASP.NET MVC framework provides an alternative to the ASP.NET Web Forms pattern for creating MVC-based Web applications. The ASP.NET MVC framework is ......
1. 打开新的窗口并传送参数:
传送参数:
response.write("<script>window.open('*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"')</script>")
接收参数:
string a = Request.QueryString("id");
string b = Request.QueryString("id1");
2.为按钮添加对话框
Button1.Attribute ......
SQL
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
--阿会楠sosuo8.com根据网络上的代码进行了修改,版权归原作者所有2009-4-5
--阿会楠做了一次升级,2009-9-27
--修改输出总记录数
ALTER PROCEDURE [dbo].[pagination]
@tblName nvarchar(1000), -- 表名
......