Saturday, December 18, 2010

ASP: Why in C Sharp or java not having Pointer ?

ASP: which is fast way of string concatation?

Why in C Sharp or java not having Pointer ?

Because in C Sharp CLR is Work Memory management.It will change location in milliseconds or Address is not Fixed.that's way not having pointer.This same thing in Java. Same work do in java By JVM.

Thursday, December 16, 2010

Which is fast way of string concatation in asp.net?

There are two for string concatation :

1) using System.string
2)using System.stringbuilder
In system.string concatation base on pass by Value
For Example:- str1=str2+str3;
In System.stringbuilder base on pass by Reference
For Example:- str1=str2.append(str3);
2nd is Fast way of concatation.

Tuesday, December 14, 2010

AdRotate Control in Asp.net

For AdRotate Control one xml file add
/* XMLFile.xml file */
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
  <Ad>
    <ImageUrl>~/Upload/button_half_small_hover.gif</ImageUrl>
    <NavigateUrl>http://www.Asp13.blogspot.com</NavigateUrl>
  </Ad>
  <Ad>
    <ImageUrl>~/Upload/tfile-m.jpg</ImageUrl>
    <NavigateUrl>http://www.Google.com</NavigateUrl>
  </Ad>
</Advertisements>
In thia file all Tags are Default Do not Chage it. otherwise it will not work.

/*  Home.aspx */

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Home.aspx.cs" Inherits="Home" %>

<!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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:adrotator ID="Adrotator1" runat="server"  AdvertisementFile="~/XMLFile.xml"></asp:adrotator>
    </div>
    </form>
</body>
</html>

File Upload Control in Asp.net

1st of all add name space Using System.IO
After that following is Theory of File Upload Control in Asp.Net
1)We not need Source address only need Destination Address so we map destination address which is on  server
2)We make fullpath=filepath+finename
3)(Optional)If we need file extension
4) (Optional)File size checking.
5)Save file.
/*Upload.aspx.cs   file*/
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;

public partial class AboutUs : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        /*
         1)File Upload need Using System.IO namespace
         2)We not need Source address only need Destination Address so we map destination address which is on server
         3)We make fullpath=filepath+finename  
         4)(Optional)If we need file extension 
         5)Save file.
         
         */
        string filename = FileUpload1.FileName;
        string filepath = Server.MapPath("Upload" + "//");
        string fullfilepath = filepath+filename;
        string extension = Path.GetExtension(filename);
        lbltext.Text = filepath;
        int filesize = FileUpload1.PostedFile.ContentLength/1024;
        int i = 0;
        if (extension == ".jpg" || extension == ".gif")
        {
            if (filesize < 10)
            {
                FileUpload1.SaveAs(fullfilepath);
                i = 1;
            }
            else
            {
                lbltext.Text = "Filesize Exceed 10KB.";
            }
        }
        else
        {
            lbltext.Text = extension; 
        }
        if (i == 1)
        {
            Image1.ImageUrl = "~/Upload/" + filename;

        }
    }
}


/*Upload.aspx */

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AboutUs.aspx.cs" Inherits="AboutUs" %>

<!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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:FileUpload ID="FileUpload1" runat="server" />
        <asp:Button ID="btnSave" runat="server" Text="Save" onclick="btnSave_Click" />
    </div>
    <asp:Label ID="lbltext" runat="server"></asp:Label>
    <div>
        <asp:Image ID="Image1" runat="server" />
    </div>
    </form>
</body>
</html>

Saturday, December 4, 2010

Difference between asp and asp.net ?

First of all i clearyfied that asp.net is not upgrade version of asp.
  1. Asp.Net Use .net framework where as asp not use .net framework.
  2. Asp.net is programming language where as asp is script language.
  3. asp.net is use ADO.Net where as asp use ADO.
  4. ASP.Net is Slower than ASP where as ASP is Faster than ASP.Net(asp is script and script is interpreted ASP.Net is Compile two times.)

Friday, December 3, 2010

Why ASP.Net?

Microsoft Develop .net Which is not platform independent. At time java also available which platform independent so microsoft develop Framework.Which is Platform independent. .net + Framework = .net framework.Most of language we can use with framework and we can develop application.
ASPdotNET-Example