Asp.net 文件上传(Vb.net版)
在Asp.net中实现文件的上传功能,是非常简单的一件事情,只需要利用微软提供的FileUpload控件即可轻松实现。
LargeFileUpload.aspx代码如下
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="LargeFileUpload.aspx.vb"
Inherits="LargeFileUpload" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Upload LargeFile</title>
</head>
<body>
<form id="form1" runat="server" enctype="multipart/form-data">
<! 注意在form中必须有enctype="multipart/form-data",表示表单中有上传文件,否则文件无法上传>
<div>
<center>
<asp:FileUpload ID="FileUpload1" runat="server" Width="336px" /><br />
<!runat="server" 表示此控件是服务器控件>
<asp:Button ID="btnUpload" runat="server" Text="Upload" />
<asp:Button ID="btnReset" runat="server" Text="Reset" />
</center>
</div>
</form>
</body>
</html>LargeFileUpload.aspx.vb代码如下:Partial Class LargeFileUpload
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Me.IsPostBack Then
'Upload file
Call UploadFiles()
End If
End Sub
Private Sub UploadFiles()
Try
相关文档:
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 ......
ASP.NET程序中常用代码汇总
1.自定义异常处理
//自定义异常处理类
using System;
using System.Diagnostics;
namespace MyAppException
{
/// <summary>
/// 从系统异常类ApplicationException继承的应用程序异常处理类。
/// 自动将异常内容记录到Windows NT/2000的应用程序日志
/// </summary>
......
前言:当一个Http请求发送给一个aspx页面时,服务器进行了哪些操作?又如何来解析这个请求?ASP.NET在接收请求后是怎么运行的,如怎么编译以及怎么样用托管的代码来运行的?.....理解这些问题,使我们可以更加好的开发ASP.NET。
1.当我们在浏览器中请求一个ASP.NET网站的某个页面的时候,如,我们在浏览器中输入" ......
首先法方有3个,这里就说2个实用的。。。
1,直接为 控件 innerhtml 添加值
2,createElement (创建COM)
3,后台 NEW 控件,添加
这里说下 1,2 两个法方!
1:
动态生成 字符串 string inntext=" <table> <tr> <td style=width:300px;text-align:right; >{0}<input id={1} type=text c ......
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 ......