Content feed Comments Feed

The Official ASATO Site

Hi, welcome to my blog. ASP,asp.net,Health,Javascript,JQUERY

Archive for April, 2009

How to upload a file by using jquery and asp.net

Posted by admin On April - 20 - 2009

maybe the title not right.bu i think you can understand my means.

In the asp.net world,we frequently uploading files via a web page, in this example,we will upload a file without refresh.

index.html:

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!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>
    <title>无标题页</title>
    <script type="text/javascript" src="../js/jquery-1.3.2.min.js"  charset="GB2312"></script>
    <script type="text/javascript">
    $(function() {
	$("#btnUploadFile").click(function(){
 
	    $.ajax({
        type: "post",
        dataType:"html",
        url: "upload.aspx",
        timeout: 20000,
        data: "userfile="+escape($("#userfile").val()),
        cache:false,
        beforeSend: function(XMLHttpRequest){
            //ShowLoading();
        },
        success: function(data,textStatus){
            $("#dialog").html(data);
            alert("succeed");
        },
        complete: function(XMLHttpRequest, textStatus){
            //HideLoading();
        },
        error: function(){
            //HappenError();
        }
    });
	});
});
</script>
</head>
<body>
<form id="form1" method="post" enctype="multipart/form-data">
<div>
    <input id="userfile" type="file" /><input id="btnUploadFile" type="button" value="upload" /></div><div id="dialog"></div>
</form>
</body>
</html>

upload.aspx

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Net" %>
<script runat="server">
    protected void Page_Load(object sender, EventArgs e) {
        string requestpath = Request.Form["userfile"].ToString();
        string _path = "../Users/";//
        string extName = "";//
        string fileNamePath = ""; //
        string NewFilePath = "";//
        FileInfo userPostedFile = new FileInfo(Server.UrlDecode(requestpath));
        if (userPostedFile.Length > 0) {
            extName = userPostedFile.Extension;
            if (_path.EndsWith("/") == false)
                _path = _path + "/";
            fileNamePath = HttpContext.Current.Server.MapPath(_path);
            NewFilePath = fileNamePath + DateTime.Now.ToString("yyyyMMddHHmmss") + extName;
            WebClient myWebClient = new WebClient();
            myWebClient.Credentials = CredentialCache.DefaultCredentials;
            FileStream fs = new FileStream(Server.UrlDecode(Context.Request.Form["userfile"]), FileMode.Open, FileAccess.Read);
            BinaryReader r = new BinaryReader(fs);
            byte[] postArray = r.ReadBytes((int)fs.Length);
            Stream postStream = myWebClient.OpenWrite(NewFilePath, "PUT");
            if (postStream.CanWrite) {
                postStream.Write(postArray, 0, postArray.Length);
                Response.Write("ok!");
            }
            else {
                Response.Write("error!");
            }
            postStream.Close();
            postStream.Dispose();
        }
    }
</script>

45 Excellent Free Wordpress Themes

Posted by admin On April - 15 - 2009

There are 45 Wordpress Themes, I hope this collection would have something you like.

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

 

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

45 Excellent Free Wordpress Templates
PreviewDownload

this is the author web

5 Wordpress Themes

Posted by admin On April - 15 - 2009

Premium Car

Premium Car, A premium and 2-column car wp theme.

Premium Car

Demo

Download

Impulse MM

Impulse MM, The theme is XHTML and CSS valid, optimized for fast loading and has dynamic tabbed menu on top, allowing any page name to fit in perfectly without ruining the theme. If you have no thumbnails on your blog and just migrate to magazine style design, theme will pull ANY images you have in the post and automatically optimize them into thumbnails, which makes migrating to magazine style theme perfectly easy. Enjoy!

Plugins required: Featured Content Gallery, Cumulus, Limited posts

Impulse MM

Demo

Download

Online Casino Template 48

Online Casino Template 48, poker wordpress theme

Online Casino Template 48

Demo

Download

Online Casino Template 44

Online Casino Template 44, premium poker wordpress theme.

Online Casino Template 44

Demo

Download

Close to a Flush

Close to a Flush, theme related poker, casinos and general gambling.

Close to a Flush

Demo

Download

How to get value of select box by using javascript

Posted by admin On April - 13 - 2009

options is an array property of the Javascript select object. The options array define the options of the select box with indices starting from zero.

To grab the value* or text** of a option in the select box, you must know it’s index. Most of the time you’ll only need use of the user selected option, so we can use the select object’s selectedIndex property to get the index we want, then use that to get the value of the option we want. This code example will grab the selected value of the myselect select box:

?View Code CSHARP
1
myselect.options[myselect.selectedIndex].value

This is an select box:

?View Code CSHARP
1
2
3
4
5
<select onchange="window.location=this.options[this.selectedIndex].value">
    <option value="#">Select a search engine</option>
    <option value="http://www.google.com">Google</option>
    <option value="http://www.yahoo.com">Yahoo</option>
</select>

Load XML Documents in ASP.NET2.0

Posted by admin On April - 13 - 2009

first,creat a xml files named “e.xml”

second,we can load this XML documents by using the System.Xml.XmlDocument class.

.CS

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
XmlDocument doc = new XmlDocument();
// 1:Load the XML data from a file
doc.Load("e.xml");
// 2:Load the XML data from a file stream
FileStream fs = new FileStream("e.xml", FileMode.Open);
doc.Load(fs);
fs.Close();
// 3:Read the XML by using XmlTextReader
XmlTextReader rdr = new XmlTextReader("e.xml");
rdr.MoveToContent(); // Move to the content nodes.
rdr.Read(); // Start reading.
rdr.Skip(); // Skip the root.
rdr.Skip(); // Skip the first content node.
doc.Load(rdr); // Read the second node data into DOM.

if you want to save axml documents,you can do it like this:

?View Code CSHARP
1
doc.Save("a_File.xml");

Scarlett Johansson pops cork in new campaign

Posted by admin On April - 8 - 2009

Scarlett says she is ‘honoured’ to front the campaign

Scarlett says she is ‘honoured’ to front the campaign

The head of the champagne house says Scarlett was the ‘obvious choice’ to be the company’s celebrity ambassador

The actress holds a champagne glass between her toes in one image

Scarlett Johansson stars in a new campaign for Moët & Chandon

Scarlett Johansson proved she is indeed a bubbly blonde in a new campaign for Moët & Chandon.

The Hollywood actress looks her bombshell best in a series of smouldering images for the champagne house, who named her their first ever celebrity ambassador last month.

In one provocative image she pops the cork off a bottle of the French tipple, while in another she shows off her fancy footwork as she holds a champagne glass between her toes.

How to find control inside Repeater

Posted by admin On April - 8 - 2009

Sometimes,wo need to find some control inside a repeater,and give it some values.

wo can using this code:

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
StringBuilder sb = new StringBuilder();
foreach (RepeaterItem item in Rep.Controls) {
if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) 
{
     Literal questionid = (Literal)item.FindControl("questionid");
     HtmlTextArea hta = (HtmlTextArea)item.FindControl("txtJisuan");
     sb.Append(Server.HtmlEncode(hta.Value));
     sb.Append("$$");
}
}

if you want to find some control inside  HeaderTemplate of Repeater,you kan do this:

?View Code CSHARP
1
2
3
4
5
6
7
8
foreach (RepeaterItem item in Rep.Controls) 
{
if (item.ItemType == ListItemType.Header) 
{
Label lbSelTotal = (Label)item.FindControl("lbSelTotal");
break;
}
}

you need pay attention to the red words.

Tools of Creating an ASP.NET MVC Web Application Project

Posted by admin On April - 7 - 2009

If you want to build an ASP.NET MVC application,You’ll need either Visual Studio 2008 or Visual Web Developer 2008 Express. and You also need to download the ASP.NET MVC framework.

Here are the Tools.
90 day trial version of Visual Studio 2008

If you decide to use Visual Web Developer Express then you must have Service Pack 1 installed. You can download Visual Web Developer 2008 Express with Service Pack 1
Visual Web Developer 2008 Express with Service Pack 1

Next  I will introduce “How to Creating an ASP.NET MVC Web Application Project”.

Microsoft Office SharePoint Server 2007 Software Development Kit (SDK) describes the technologies that Office SharePoint Server 2007 provides for developers. It contains overview information and step-by-step, how-to procedures for programming with Office SharePoint Server 2007.

click this link: Start download.

what is a delegate?
a delegate is a type that defines a method signature, and can be associated with any method with a compatible signature. (MSDN)

Declaring a delegate:
public delegate int PerformCalculation(int x, int y);
or
public delegate void TestDelegate(string message);

Demo:
using System;
public delegate void TestDelegate(string message); //Declare the delegate
class Test
{
  public static void Display(string message)
  {
    Console.WriteLine("The string entered is : " + message);
  }
  static void Main()
  {
    TestDelegate t = new TestDelegate(Display); //Instantiate the delegate
    Console.WriteLine("Please enter a string");
    string message = Console.ReadLine();
    t(message); //Invoke the delegate
    Console.ReadLine();
  }
}

patterns & practices – Enterprise Library

Posted by admin On April - 1 - 2009

NewpnpheroA.jpg

The Microsoft Enterprise Library is a collection of reusable software components (application blocks) designed to assist software developers with common enterprise development challenges. Application blocks are a type of guidance; they are provided as source code plus documentation that can be used “as is,” extended, or modified by developers to use on complex, enterprise-level line-of-business development projects.

http://entlib.codeplex.com/