Saturday, 7 September 2013

Using Class File in Asp.net

1. Open Visual Studio
2. Create a New Website
3. In Solution Explorer Right Click -> Add New Item -> Class - > Give Name and Click Add->OK
4. Write the Addition method in Class File as below.

public string addition()

    {
        return (10 + 20).ToString();

    }


5. Now Add Web Page to the Site and Add Label.

6. Write code to Page_Load event as below.

 mainClass objMain = new mainClass();

    protected void Page_Load(object sender, EventArgs e)
    {
        Label1.Text = objMain.addition();

    }


7. Click F5.

No comments:

Post a Comment

Thanks

SQL server tricky questions