Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Publish or Deploy website in our local machine using asp.net

Sep 4, 2010 37 comments
Here I will explain how to publish or deploy the website in local machine. To publish website first we need to check whether IIS installed in our local machine or not and whether that IIS working properly or not because sometimes IIS will not work properly even that IIS already installed in our local machine for that reason we need to check all these conditions before going to publish or deploy our website in local machine. 

After that now open the application in visual studio whatever the application we need publish. 

How to get length of data in each Column of a table Using SQL Server

0 comments
Introduction:

Here I will explain how to get length of data in each Column of a table using SQL Server.

Description:

There is sometimes we need to figure out the maximum space that is being used by a particular column in your database.  You would initially think that the LEN() function would allow you to do this, but this function does not work on Text, NText or Image data types, so how do you figure out the length of a value in a column that has one of these data types?

Query to change column name or table name in sql server

1 comments
Introduction:

In this article I will explain how to change or rename column name or table name in SQL server.

Description:

In previous posts I explained many articles relating to SQL Server. Now I will explain how to rename or change column name or table name in SQL Server. 

Calculating the difference between two dates range is 30 days in javascript or validation to Check end date is not greater than start date and two dates range is not more than 30 days using ajax and javascript in asp.net

Aug 22, 2010 3 comments
Introduction:

Here I will explain how to check end date greater than start date and check two dates difference range is 30 days or not using asp.net.

Description:

Previously I explained how to use Ajax Collapsible panel . I explained many articles on Ajax now I will explain to how to set validation to check end date greater than start date or not and check two dates difference range is 30 days using Ajax validator controls. 


JavaScript Enable/disable Button based on text in textboxes in asp.net

9 comments
Introduction
Here I will explain how to enable/disable button whenever user enter text in textboxes using JavaScript in asp.net
Description
I have taken two textboxes and one button now I need to write functionality like to enable button if user enter text in two textboxes. For this we need to test whenever user entering text in textboxes at that time we need to raise onkeyup event for particular textbox. By default this event is not available for textbox in asp.net but we have a chance to use this event for textbox. Here I am enabling button whenever user enters text in two textboxes using JavaScript.

how to change the error message of custom validator dynamically using asp.net

2 comments
Introduction

Here I will explain how to change the error message of custom validator dynamically using asp.net.

Description

I have one textbox, one button and one custom validator to validate the textbox whenever user clicks on button.
In customvalidator I have taken ClientValidationFunction="ClientValidationFunction" this clientside function is used to send error message dynamically by using sender object. This sender object will display ErrorMessage dynamically.


Opening Child window from Parent window after selecting data from child window closing the child window and displaying that data in parentwindow using asp.net

Aug 15, 2010 2 comments

Here i will explain how to opening Child window from Parent window after selecting data from child window closing the child window and displaying that data in parent window using asp.net

Here based on my requirement i have taken one textbox and one image button i want to search for the email ids exists in database whenever the user clicks on the image button i need to open one child window like this

Calculating the differece between two dates is one month in javascript using asp.net

Aug 12, 2010 3 comments
Hi i have written one javascript function to find the two dates difference is one month

i am having two textboxes startdate and enddate. Now i want to write clientside javascript function to check the dates difference is one month or not if the user enter more than one month date range i want to raise error message.i have written it in server side but i want to write clientside javascript function to check dates range. i have searched for this many sites i have found the solution but they are finding the difference between two dates i.e number of days and they are taking by default 30 days difference for one month .Suppose user enter 2/1/2010(Feb/01/2010) and 3/3/2010(March/03/2010) how can we calculate in February we have only 28 days if we allow user up to 30 days means that not right way . So i have already written server side function for validating textboxes for date range based on that server side function i have implemented client side function (i.e.,javascript function)

Caluculating the today date minus one month in asp.net

2 comments
Now my requirement is to get the today date minus one month that is 30 days 

i will write the following code to get that like the date

 tbStartDate.Text = DateTime.Today.AddDays(-30).ToShortDateString();

by using above statement we can get the value of today date minus  one month




Lightbox Effect For Login Page in asp.net

Aug 11, 2010 27 comments
Introduction

Here I will explain how to create lightbox effect for Login Page in asp.net

Description:

One day I got requirement like showing login page with popup window at that time I used lightbox effect for my login page to display in popup window.

To display login page with lightbox effect First we need to desgin Login Page like this

Call javascript function from codebehind in asp.net

Aug 9, 2010 18 comments
Here i will explain how to call javascript function from codebehind without assigning it to any control in asp.net.

We can call javascript functions in two ways

first way is


 System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Script", "document.getElementById('" + button2.ClientID + "').style.display='none';", true);
Seconda way you can call javascript function also

Customized CSS Styles for AJAX Calendar Control

Jul 30, 2010 13 comments
Introduction

Here I will explain how change the appearance of ajax calendar using CSS Styles.

Description

In so many situations I have used calendar control but I didn’t tried to change CSS style of calendar control in one project I got requirement like to match calendar control style to project default colors at that time I changed calendar control style by using following CSS style classes.

First add Ajax tollkit reference to your project and register that ajax referece like this in your aspx page

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

After that design your aspx like this

Read the data from Excel Sheet and bind it to Gridview in asp.net

Jun 21, 2010 33 comments
Here i will explain how to read the data from Excel sheet and bind that data to gridview in asp.net

1) First take one upload control, one button and one gridview like this


How to Make Some cells Read only in Excel Sheet and other should be editable

13 comments
In Excel sheet we can make some cells read only and some cells editable by using these following steps

1) First Select whole Excel Sheet by Ctrl+A After that

2) Right Click on excel sheet you will find Format Cells Option that screen look like this



3 tier architecture example in asp.net with C#

May 17, 2010 226 comments
Introduction

Here I will explain about uses of 3-Tier architecture and how to create or implement 3-tier architecture for our project in asp.net 

Description

1.    What is the use of 3-tier architecture and why we go for that architecture? 
2.    First we need to know what 3-Tier architecture is. 
3.    How to create 3-Tier architecture for our project?

WPF (Windows Presentation Foundation) in .NET

May 12, 2010 22 comments
Windows Presentation Foundation (WPF)
The Windows Presentation Foundation is Microsoft’s next generation UI framework to create applications with a rich user experience. It is part of the .NET framework 3.0 and higher.
WPF combines application UIs, 2D graphics, 3D graphics, documents and multimedia into one single framework. Its vector based rendering engine uses hardware acceleration of modern graphic cards. This makes the UI faster, scalable and resolution independent.

Cursors in SQL Server

May 10, 2010 6 comments
Cursors can be considers as named result sets which allow a user to move through each record one by one. SQL Server 2000 provides different types of cursors to support different type of scrolling options. 
When we use a Select statement in a stored procedure to get some result, we can get a collection of all the records which satisfy the given criteria. This result set can be returned back as a whole to the client application. We can’t move through each individual record one by one in this situation inside a stored procedure. Therefore, whenever we find some situation where we need to process each record individually we can use cursors. 

Publishing Web Site in asp.net

May 5, 2010 2 comments

Here I will explain how to publish or deploy the website in local machine. To publish website first we need to check whether IIS installed in our local machine or not and whether that IIS working properly or not because sometimes IIS will not work properly even that IIS already installed in our local machine for that reason we need to check all these conditions before going to publish or deploy our website in local machine. 

C# Coding Standards and Best Programming Practices

Apr 26, 2010 31 comments


Anybody can write code. With a few months of programming experience, you can write 'working applications'. Making it work is easy, but doing it the right way requires more work, than just making it work.

Believe it, majority of the programmers write 'working code', but not ‘good code'. Writing 'good code' is an art and you must learn and practice it.

Everyone may have different definitions for the term ‘good code’. In my definition, the following are the characteristics of good code.

·         Reliable
·         Maintainable
·         Efficient

How to Merger the two datatbles into one table in asp.net

Apr 22, 2010 7 comments
It is very easy to merge two data tables into one table in asp.net 

Using Merge Method ucan add two tables

 DataTable dt = new DataTable();
 
DataTable dt1 = new DataTable();

dt.Merge(dt1);

 I think it helps you

Introduction to Object Oriented Programming Concepts (OOPS) in C#.net

Apr 16, 2010 502 comments
OOPS Concepts

Class:

 It is a collection of objects.

Object:

It is a real time entity.
An object can be considered a "thing" that can perform a set of related activities. The set of activities that the object performs defines the object's behavior. For example, the hand can grip something or a Student (object) can give the name or address. In pure OOP terms an object is an instance of a class

Set Color of GridLines in Gridview

4 comments
There are times when you will want to set the color of the grid lines in your GridView - however there is not to my knowledge a way of doing this declaratively. A workaround is to do this by tapping into the GridView's RowDataBound event.


First, set the OnRowDataBound property in the markup of the GridView:

OnRowDataBound="MyGrid_RowDataBound"

Second, set the color in the OnRowDataBound handler method:

protected void MyGrid_RowDataBound(object sender, GridViewRowEventArgs e)
    {

        foreach (TableCell tc in e.Row.Cells)
        {

            tc.Attributes["style"] = "border-color: #c3cecc";

        }

    }

Happy Coding

Setting up your ASP.NET server (IIS)

Apr 15, 2010 1 comments
  A guide that shows you how to install IIS server and configure it to work with ASP.NET, not just with ASP.

Before starting, be sure you have .NET Framework installed. If not, you can install it using Windows Update or download the package and install manually.

ASP runs inside IIS (Internet Information Services). Therefore first you should install IIS (under Windows 2000, Windows XP or Windows 2003), of course if it isn't already installed.
Usually, you can install it from Control Panel / Add or Remove Programs / Add/Remove Windows Components.

Go to Start Menu / All Programs / Administrative Tools / Internet Information Services.
Choose your computer name (local computer) / Web Sites / Default Web Site.
Right click 'Default Web Site' and select 'Properties'. Choose the 'Home Directory' tab and type in the 'Local Path' the path to where you want your files to be stored. For example 'D:\Server\iis'. This is the root of your webserver, this folder will open when you type http://localhost in your web broswer.
Below, check the 'Script source access', 'Read', 'Write' and 'Directory browsing' values. Click OK and now let's start the server.

Click on the 'Start item' button to start the service. Be sure you don't have any other server running on localhost, Apache for example.


Changing the Color of Selected item in menu using javascript

Apr 8, 2010 6 comments
In header Section you should write the this script function


<script language="javascript">
var selectEl = null; // keep track of currently selected
function mo(el) {
    if (selectEl) { // unselect selected
        selectEl.style.backgroundColor = 'gray';
        selectEl.style.border = '0px inset black';
    }
    selectEl = el; // new selected
    el.style.backgroundColor = 'navy';
}
</script>

Detect Browser Refresh to avoid events fired again in ASP.NET

Apr 6, 2010 21 comments

If you have created an aspx page using C# and ASP.NET and have put a button on it. And in the Click event of this button if you are inserting some data in database , after click if user refresh the page than click event gets fired again resulting data insertion to database again, to stop events on the page getting fired on browser refresh we need to write bit of code to avoid it.

In this example I’ve put a Label and a Button on the page, on click the label Text becomes Hello and when I refresh the page label's text again becomes Hello

Generating Random Number and String in C# or Generating the Password Automatically By using asp.net with c#

12 comments

Hi friends here I have written the code to generate the auto generated password 

open the visual studio 
select the new website

After that copy and paste the following code in aspx page

C# - Difference between Abstract class and Interface in Asp.Net

56 comments
In previous article I explained complete OOPS Concept. Now I will explain differences between Abstract classes and Interfaces.

An Abstract class without any implementation just looks like an Interface; however there are lot of differences than similarities between an Abstract class and an Interface. Let's explain both concepts and compare their similarities and differences.

What is an Abstract Class?

An abstract class is a special kind of class that cannot be instantiated. So the question is why we need a class that cannot be instantiated? An abstract class is only to be sub-classed (inherited from). In other words, it only allows other classes to inherit from it but cannot be instantiated. The advantage is that it enforces certain hierarchies for all the subclasses. In simple words, it is a kind of contract that forces all the subclasses to carry on the same hierarchies or standards.

Maintaining State of CheckBoxes While Paging in a GridView Control

Apr 3, 2010 36 comments
Introduction:
In this article I will explain how to maintain state of selected checkboxes during paging in gridview using asp.net
Description:

I have one gridview with checkboxes and it contains lot of data for that reason I applied paging for gridview and displaying 8 records per page. After apply the paging in gridview if I select checkboxes in first page and moving to another page and select some checkboxes in second page after that if I come back I am unable to see the previous selected values. At that time I know one new thing that is gridview won’t maintain the state of controls during postback for that reason we need write some code to maintain the previous selected values in gridview. Before seeing the code implemention first Design your aspx page like this

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.