Saturday, 25 January 2014


Description:-

            In this example we explain that how to create a event dates in List format with event title and event description in mvc4.

In my events web site I need to show event dates in lists format so users can easily see them and understand it.. As there are more than one view where I need this functionality I wrote HTML extension method that outputs day calendar view based on current date. In this posting I will show you my extension method and show you how to use it.

DayCalendarPage extension method

Here is the extension method that generates day calendar page like shown above.

public static MvcHtmlString DayCalendarPage(this HtmlHelper helper, DateTime date)
{
   
var buffer = new StringBuilder();
    buffer.Append(
@"<div class=""dayCalendarPage"">");

    buffer.Append(
@"    <div class=""title"">");
    buffer.Append(date.ToString(
"MMM"));
    buffer.Append(
@"    </div>");

    buffer.Append(
@"    <div class=""day"">");
    buffer.Append(date.ToString(
"dd"));
    buffer.Append(
@"    </div>");

    buffer.Append(
@"</div>");

   
return MvcHtmlString.Create(buffer.ToString());
}

This method outputs HTML that is made to nice day calendar page using CSS.

CSS

Here is my CSS that makes calendar look nice. It is not very optimal I think but it works.

/* DAY CALENDAR PAGE */ 
.dayCalendarPage
{
     clear:none;
     float:left;
     text-align:center
     border:1px solid lightgrey
     margin-right:10px;
}
.dayCalendarPage .title
{
     background-color:Red;
     color:White;
     width:50px;    
}
.dayCalendarPage .day
{
     font-size:15pt;
     font-weight:bold;
     padding-top: 5px;
     padding-bottom: 5px;
}

Now as you have extension method and styles added to your project it is time to use them.

How to use DayCalendarPage method

Here is the example about how to use DayCalendarPage extension method.

@foreach (var item in Model.Results) {
    
<tr>
       
<td colspan="10">
           @Html.DayCalendarPage(item.StartDate)
          
<div>
              @Html.ActionLink(item.Title,
"event", new { id = item.Id})
             
<br />
              @item.Description
          
</div>
      
</td>
   
</tr>
}

to sorting data in gridview with up and down arrow sorting data in gridview in asp.net

change the background of gridview row when mouse is hover changebackground color of gridview in asp.net

to implement this you have to follows this step
1)create table with coloumn id,title,description in sqlserver.
2) create the Linqtosql Dataclasses and and drag and drop the table that you are created.

mvc example for displaying or Showing dates using DayCalendarPage extension method


Description:-

            In this example we explain that how to create a event dates in List format with event title and event description in mvc4.

In my events web site I need to show event dates in lists format so users can easily see them and understand it.. As there are more than one view where I need this functionality I wrote HTML extension method that outputs day calendar view based on current date. In this posting I will show you my extension method and show you how to use it.

DayCalendarPage extension method

Here is the extension method that generates day calendar page like shown above.

public static MvcHtmlString DayCalendarPage(this HtmlHelper helper, DateTime date)
{
   
var buffer = new StringBuilder();
    buffer.Append(
@"<div class=""dayCalendarPage"">");

    buffer.Append(
@"    <div class=""title"">");
    buffer.Append(date.ToString(
"MMM"));
    buffer.Append(
@"    </div>");

    buffer.Append(
@"    <div class=""day"">");
    buffer.Append(date.ToString(
"dd"));
    buffer.Append(
@"    </div>");

    buffer.Append(
@"</div>");

   
return MvcHtmlString.Create(buffer.ToString());
}

This method outputs HTML that is made to nice day calendar page using CSS.

CSS

Here is my CSS that makes calendar look nice. It is not very optimal I think but it works.

/* DAY CALENDAR PAGE */ 
.dayCalendarPage
{
     clear:none;
     float:left;
     text-align:center
     border:1px solid lightgrey
     margin-right:10px;
}
.dayCalendarPage .title
{
     background-color:Red;
     color:White;
     width:50px;    
}
.dayCalendarPage .day
{
     font-size:15pt;
     font-weight:bold;
     padding-top: 5px;
     padding-bottom: 5px;
}

Now as you have extension method and styles added to your project it is time to use them.

How to use DayCalendarPage method

Here is the example about how to use DayCalendarPage extension method.

@foreach (var item in Model.Results) {
    
<tr>
       
<td colspan="10">
           @Html.DayCalendarPage(item.StartDate)
          
<div>
              @Html.ActionLink(item.Title,
"event", new { id = item.Id})
             
<br />
              @item.Description
          
</div>
      
</td>
   
</tr>
}

to sorting data in gridview with up and down arrow sorting data in gridview in asp.net

change the background of gridview row when mouse is hover changebackground color of gridview in asp.net

to implement this you have to follows this step
1)create table with coloumn id,title,description in sqlserver.
2) create the Linqtosql Dataclasses and and drag and drop the table that you are created.

This entry was posted in :

Thursday, 23 January 2014



Description:-

            In this example we explain that how to create controls dynamically like TextBox,DropdownList etc… in asp.net and retrieve the values of the dynamically created  control and access it.

In which example we created Textbox for name field,another Textbox for salary field and DropdownList for  age field and when user enter data into this dynamic control and click on submit button the data is inserted in database and bind it in Gridview Dynamically.



Look at this user enter 5 in textbox then 5 rows dynamically created and fillup the data and click on submit button then all 5 rows will be inserted in database.


Ajax password checker example Check the Strength of Password using ajax in asp.net

How to handle concurrency in Linq to sql Concurrency Example linq to sql in asp.net

Example of Royal flush in css Royal flush example using CSS

to download complete Example click below download link

download here!


How to create dynamic controls in ASP.NET and retrieve's values from it



Description:-

            In this example we explain that how to create controls dynamically like TextBox,DropdownList etc… in asp.net and retrieve the values of the dynamically created  control and access it.

In which example we created Textbox for name field,another Textbox for salary field and DropdownList for  age field and when user enter data into this dynamic control and click on submit button the data is inserted in database and bind it in Gridview Dynamically.



Look at this user enter 5 in textbox then 5 rows dynamically created and fillup the data and click on submit button then all 5 rows will be inserted in database.


Ajax password checker example Check the Strength of Password using ajax in asp.net

How to handle concurrency in Linq to sql Concurrency Example linq to sql in asp.net

Example of Royal flush in css Royal flush example using CSS

to download complete Example click below download link

download here!




Description:-

            In Previous Example We Explain that How to Export Gridview or Webgrid Data to MS Word or MS Excel sheet in MVC4.but now in this example we explain that how to redirect one page to another page in mvc or redirect from Controller to view page in mvc.

This is simple just you can pass the url in controller method and in which we create a code to redirect to the specified URL argument like

<form action="/Home/Goto" method="post">
    <label for="gotourl">url:</label>
    <input type="text" name="gotourl" />
    <input type="submit" />
    </form>

In above code you enter the url of the page that you want to redirect and when click on submit button then it will call the Goto method of the Homecontroller like
public ActionResult Goto(string gotourl)
        {
         

            return Redirect(gotourl);
        }

Look at this method simple redirect the page with  gotourl argument that you can enter in the Textbox.
The main thing keep in mind is that  <input type="text" name="gotourl" /> name of textbox and argument of method both are same like name of textbox gotourl and argument of the method like public ActionResult Goto(string gotourl) must be same that you are define in controller method.


Implement Remember Me functionality using CheckBox ASP.Net 

set WaterMark Text in PDF using itextsharp in C#

How to set Default Button in MVC Web Form Application 

How to Bind XML File data to Treeview in asp.net

JQuery datepicker calender with Dropdown month and year in asp.net. 


How to redirect to another page from MVC controller in mvc4



Description:-

            In Previous Example We Explain that How to Export Gridview or Webgrid Data to MS Word or MS Excel sheet in MVC4.but now in this example we explain that how to redirect one page to another page in mvc or redirect from Controller to view page in mvc.

This is simple just you can pass the url in controller method and in which we create a code to redirect to the specified URL argument like

<form action="/Home/Goto" method="post">
    <label for="gotourl">url:</label>
    <input type="text" name="gotourl" />
    <input type="submit" />
    </form>

In above code you enter the url of the page that you want to redirect and when click on submit button then it will call the Goto method of the Homecontroller like
public ActionResult Goto(string gotourl)
        {
         

            return Redirect(gotourl);
        }

Look at this method simple redirect the page with  gotourl argument that you can enter in the Textbox.
The main thing keep in mind is that  <input type="text" name="gotourl" /> name of textbox and argument of method both are same like name of textbox gotourl and argument of the method like public ActionResult Goto(string gotourl) must be same that you are define in controller method.


Implement Remember Me functionality using CheckBox ASP.Net 

set WaterMark Text in PDF using itextsharp in C#

How to set Default Button in MVC Web Form Application 

How to Bind XML File data to Treeview in asp.net

JQuery datepicker calender with Dropdown month and year in asp.net. 


This entry was posted in :

Sunday, 19 January 2014




Description:-

            In previous Example we Explain that How to Export Gridview data to Excelsheet in MVC  Export Gridview data to excelsheet in asp.net but now in this example we explain that how to Export Gridview Data to MS word in MVC4.

This is very useful when we have to generally Create a Report or you can Directally print the Document

you have to set Content Type of the page Before sending or Exporting data to ExcelSheet like
Response.ContentType = "application/ms-word";

to show example of WCF service for insert,update,delete CRUD operation using WCF service

check the Extention of file when upload upload only image or word file

there are number of steps to follow how to Export or transfer Gridview or webgird data to Excelsheet Database file.

step 1:- First create a LinqtoSQL class in Model folder and drag and srop the table that you have to use in example.

step 2:- create a controller like exportgridtoexcel in controller Folder.

step 3:- create a view page For display the details we have to create a view page for that in the exportgridtoexcel controller add following code.



   DataClasses1DataContext dc = new DataClasses1DataContext();
        public ActionResult Index()
        {
            var lst = (from p in dc.movies select p).ToList();
            return View(lst);
        }

step 4:-Then for export the data to excel add following code to the exportgridtoexcel Controller



   public List<movie> fetch()
        {
             var lst = (from p in dc.movies select p);
            return lst.ToList();
        }

        public ActionResult ExportData()
        {
            GridView gv = new GridView();
            gv.DataSource =fetch();
            gv.DataBind();
            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment; filename=Marklist.doc");
            Response.ContentType = "application/ms-word";
            Response.Charset = "";
            StringWriter sw = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            gv.RenderControl(htw);
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();

            return RedirectToAction("Index");
        }



MVC Example for Export or transfer Gridview Data to MS Word File in MVC4




Description:-

            In previous Example we Explain that How to Export Gridview data to Excelsheet in MVC  Export Gridview data to excelsheet in asp.net but now in this example we explain that how to Export Gridview Data to MS word in MVC4.

This is very useful when we have to generally Create a Report or you can Directally print the Document

you have to set Content Type of the page Before sending or Exporting data to ExcelSheet like
Response.ContentType = "application/ms-word";

to show example of WCF service for insert,update,delete CRUD operation using WCF service

check the Extention of file when upload upload only image or word file

there are number of steps to follow how to Export or transfer Gridview or webgird data to Excelsheet Database file.

step 1:- First create a LinqtoSQL class in Model folder and drag and srop the table that you have to use in example.

step 2:- create a controller like exportgridtoexcel in controller Folder.

step 3:- create a view page For display the details we have to create a view page for that in the exportgridtoexcel controller add following code.



   DataClasses1DataContext dc = new DataClasses1DataContext();
        public ActionResult Index()
        {
            var lst = (from p in dc.movies select p).ToList();
            return View(lst);
        }

step 4:-Then for export the data to excel add following code to the exportgridtoexcel Controller



   public List<movie> fetch()
        {
             var lst = (from p in dc.movies select p);
            return lst.ToList();
        }

        public ActionResult ExportData()
        {
            GridView gv = new GridView();
            gv.DataSource =fetch();
            gv.DataBind();
            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment; filename=Marklist.doc");
            Response.ContentType = "application/ms-word";
            Response.Charset = "";
            StringWriter sw = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            gv.RenderControl(htw);
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();

            return RedirectToAction("Index");
        }



Thursday, 16 January 2014




Description:-

            In previous example we allready expalin that how to perform Insert,Update,Delete in Gridview without Postback using Jquery/Ajax.but now in this example we explain how to Load Asp.Net usercontrol(.ascx control) in aspx webpage without Postback using Jquery Ajax in asp.net.we can also Load the css or javascript that are define in usercontrol.


What is UserControl

.Net provide a  Web server controls by using this in your ASP.NET Web pages, you can easily create our own custom, reusable controls using the same techniques as you use for creating ASP.NET Web pages and these controls are known as user controls.

A user control is a kind of composite control that works much like an ASP.NET Web page andYou can easily embed them in ASP.NET Web pages in which they act as a unit.
 


This is very useful example when that type of problem you faced like

For Example:-

I have a ASP.Net(C#) page. When a user selects a value in dropdownlist, some new controls will be visible to him. I am able to that now, but the page has to reload every time and state has to be maintained between postbacks.

So in this sitution you can easily Load the control without Postback or PageLoad.


Dynamically Bind Data in Ajax Accordion Panel Bind Data to Accordion from databse

Restrict the size of File when Uploaded How to Restrict the size of File when uploaded by user

Dynamically Read/Write File in asp.Net How to Read Write File in Asp.Net using C#

Load UserControl Dynamically using Jquery Ajax in Asp.Net without Postback




Description:-

            In previous example we allready expalin that how to perform Insert,Update,Delete in Gridview without Postback using Jquery/Ajax.but now in this example we explain how to Load Asp.Net usercontrol(.ascx control) in aspx webpage without Postback using Jquery Ajax in asp.net.we can also Load the css or javascript that are define in usercontrol.


What is UserControl

.Net provide a  Web server controls by using this in your ASP.NET Web pages, you can easily create our own custom, reusable controls using the same techniques as you use for creating ASP.NET Web pages and these controls are known as user controls.

A user control is a kind of composite control that works much like an ASP.NET Web page andYou can easily embed them in ASP.NET Web pages in which they act as a unit.
 


This is very useful example when that type of problem you faced like

For Example:-

I have a ASP.Net(C#) page. When a user selects a value in dropdownlist, some new controls will be visible to him. I am able to that now, but the page has to reload every time and state has to be maintained between postbacks.

So in this sitution you can easily Load the control without Postback or PageLoad.


Dynamically Bind Data in Ajax Accordion Panel Bind Data to Accordion from databse

Restrict the size of File when Uploaded How to Restrict the size of File when uploaded by user

Dynamically Read/Write File in asp.Net How to Read Write File in Asp.Net using C#

Wednesday, 15 January 2014





DetailsView control in ASP.NET is used to display the Details of the master record in a table format or single record at a time. You can easily insert, update, delete and paging to data items in DetailsView. In this example we explain that how to perform Insert,Update,Delete Operation in Detailview in Asp.Net.

The idea behind using the DetailsView control is nothing but displaying the Details of the master. By default, the DetailsView control displays each field of a record on its own line. The DetailsView control displays only a single data record at a time, even if its data source contain more than one records.

The DetailsView control is typically used for display the detail of master record in a master/detail scenario where the selected record of the master control determines the record to display in the DetailsView control. The DetailsView control does not support sorting but it supports paging.

there are three modes of the Detailsview are as follows:



DetailsViewMode.Edit :-the Detailview is in Editmode and allows user to edit and update record.
DetailsViewMode.Insert :- the Detailview is in Insertmode and allows user to insert the new record.
DetailsViewMode.ReadOnly : the Detailview is in readonly mode and is the normal display mode of Detailview


to insert,update,delete in Repeator control click here Insert,Update,Delete in Repeator control in Asp.Net

Ajax Password Strength Example Password checker like good,medium,loose etc

Javascript validation for enter only number in textbox Disable all keys except number using javascript

Insert, Update, Delete in DetailsView in ASP.NET





DetailsView control in ASP.NET is used to display the Details of the master record in a table format or single record at a time. You can easily insert, update, delete and paging to data items in DetailsView. In this example we explain that how to perform Insert,Update,Delete Operation in Detailview in Asp.Net.

The idea behind using the DetailsView control is nothing but displaying the Details of the master. By default, the DetailsView control displays each field of a record on its own line. The DetailsView control displays only a single data record at a time, even if its data source contain more than one records.

The DetailsView control is typically used for display the detail of master record in a master/detail scenario where the selected record of the master control determines the record to display in the DetailsView control. The DetailsView control does not support sorting but it supports paging.

there are three modes of the Detailsview are as follows:



DetailsViewMode.Edit :-the Detailview is in Editmode and allows user to edit and update record.
DetailsViewMode.Insert :- the Detailview is in Insertmode and allows user to insert the new record.
DetailsViewMode.ReadOnly : the Detailview is in readonly mode and is the normal display mode of Detailview


to insert,update,delete in Repeator control click here Insert,Update,Delete in Repeator control in Asp.Net

Ajax Password Strength Example Password checker like good,medium,loose etc

Javascript validation for enter only number in textbox Disable all keys except number using javascript

Monday, 13 January 2014



sometimes you faced sitution like more than one submit buttons on the same form in mvc razor. At that time, how we  will handle the click event of each and every buttons on your form?

To overcome this problem  I am going to explain the various techniques for handling multiple buttons on the same form in MVC. Suppose you have a user Login form like as below:





In the above fig. we have Signup,SignIn and cancel buttons. Suppose on Signup button click you have to open Signup window & on SingnIn button click you have to open Login window and on Cancel button click you are returning to home page. For handling all of the above buttons click we have the three methods as mention below:

In this way each submit button will post the form to server but provides the different values Like SighIn, Signup,Cancel and NULL respectively for the commands.so by using this command argument we can easily implement our own logic in the controller's action method.

Export Gridview to Excel :-   Gridview to Excel
 
Insert,Update,Delete in ModalPopup CRUD operation in ModalPopup

Read and Write in Text File in asp.Net Read and Write File in Asp.Net


Handling multiple submit buttons on the same form in MVC



sometimes you faced sitution like more than one submit buttons on the same form in mvc razor. At that time, how we  will handle the click event of each and every buttons on your form?

To overcome this problem  I am going to explain the various techniques for handling multiple buttons on the same form in MVC. Suppose you have a user Login form like as below:





In the above fig. we have Signup,SignIn and cancel buttons. Suppose on Signup button click you have to open Signup window & on SingnIn button click you have to open Login window and on Cancel button click you are returning to home page. For handling all of the above buttons click we have the three methods as mention below:

In this way each submit button will post the form to server but provides the different values Like SighIn, Signup,Cancel and NULL respectively for the commands.so by using this command argument we can easily implement our own logic in the controller's action method.

Export Gridview to Excel :-   Gridview to Excel
 
Insert,Update,Delete in ModalPopup CRUD operation in ModalPopup

Read and Write in Text File in asp.Net Read and Write File in Asp.Net


This entry was posted in :

Wednesday, 8 January 2014




Description:-

            In previous example we already explain that how to create footer toatal or grand total in Gridview in Asp.Net but now        In this Example we explain that how to Display or maintain footer total or grandtotal in Gridview or webgrid with Paging facility in mvc4.

Here is a code for how to maintain or Display Grantotal or Footer total in Webgrid

<script type="text/javascript">
    $(document).ready(function () {
        var total = 0;
      
        $('#grid .Salary').each(function () {
            total = total + parseFloat($(this)[0].innerHTML.toLocaleString());
          
        });
        $('tbody').append('<tr><td><b>Total</b></td><td><b>' + total.toFixed(2) + '</b></td></tr>');
    });
</script>

Look at this above code we use Jaquery for Append the Footer template in webgrid in which function it will read webgrid row one by one and calculate the total of the all rows and finally append to the webgrid as a Footer.

to do this you have to first create the table like below with name poll and create Linqtosql dataclasses in Model folder and drag and drop this table.

 Create Nested Gridview in asp.Net Nested Gridview example

File Upload Example in MVC4 Upload File and bind to Gridview

Read/Write File in asp.net Read/write file using c#

to download complete example click below download image link
download here!

MVC Example for Display Footer or Grand total in webgrid in mvc4




Description:-

            In previous example we already explain that how to create footer toatal or grand total in Gridview in Asp.Net but now        In this Example we explain that how to Display or maintain footer total or grandtotal in Gridview or webgrid with Paging facility in mvc4.

Here is a code for how to maintain or Display Grantotal or Footer total in Webgrid

<script type="text/javascript">
    $(document).ready(function () {
        var total = 0;
      
        $('#grid .Salary').each(function () {
            total = total + parseFloat($(this)[0].innerHTML.toLocaleString());
          
        });
        $('tbody').append('<tr><td><b>Total</b></td><td><b>' + total.toFixed(2) + '</b></td></tr>');
    });
</script>

Look at this above code we use Jaquery for Append the Footer template in webgrid in which function it will read webgrid row one by one and calculate the total of the all rows and finally append to the webgrid as a Footer.

to do this you have to first create the table like below with name poll and create Linqtosql dataclasses in Model folder and drag and drop this table.

 Create Nested Gridview in asp.Net Nested Gridview example

File Upload Example in MVC4 Upload File and bind to Gridview

Read/Write File in asp.net Read/write file using c#

to download complete example click below download image link
download here!

Saturday, 4 January 2014





Description:-

            In this Example we explain that how to import/export Excel Sheet data to Sqlserver Database through File upload control in asp.net.

 We can also done this either by copy-pasting the excel rows directly to the destination Sqlserver database table in SQL Server Management Studio or by querying directly on the excel sheet from SQL Server Management Studio itself. SQL server has very easy Import/Export option and Excel itself provide easy options.

in this example we provide facility to user just browse the Excelsheet database file and click on export button then all data of the Excel Sheet File will be Automatically saved to the Sqlserver Database.

To do this First create the table with same coloumn name as we define in our Excel Sheet File like



upload multiple File at a time  in MVC Multiple File upload

Autocomplete Textbox search in ajax Autocomplete search Ajax control

Rotate Ads without Refreshing page Rotate Advertisement without loading webpage

Import/Export Excel Sheet data to Sqlserver Database through File upload in Asp.Net





Description:-

            In this Example we explain that how to import/export Excel Sheet data to Sqlserver Database through File upload control in asp.net.

 We can also done this either by copy-pasting the excel rows directly to the destination Sqlserver database table in SQL Server Management Studio or by querying directly on the excel sheet from SQL Server Management Studio itself. SQL server has very easy Import/Export option and Excel itself provide easy options.

in this example we provide facility to user just browse the Excelsheet database file and click on export button then all data of the Excel Sheet File will be Automatically saved to the Sqlserver Database.

To do this First create the table with same coloumn name as we define in our Excel Sheet File like



upload multiple File at a time  in MVC Multiple File upload

Autocomplete Textbox search in ajax Autocomplete search Ajax control

Rotate Ads without Refreshing page Rotate Advertisement without loading webpage

Thursday, 2 January 2014






Description:-

            In this Example we Explain that How to Create Registration Form with Client and Server side Validation in MVC4.Generally in which we include all control validation like Email validation,phone number validation,password validation,DropdownList validation and CheckBox validation.  

We all know that  Registration form is a common form and used in Every Application , so that reason I want to  demonstrate the basic validation in mvc4 webform. 

There are number of step to devlop the Registration form with Validation are as follows:

First in Home controller write the code for Bind the DropdownList of the Country and state just copy the below code and paste it.

Example for Insert,Update,Delete without Refreshing the webpage CRUD operation without refreshing the page using Json jquery

How to Bind Dynamic data in Ajax Accordion Control Bind data from database in Accordion control

to Download Complete Example click below Download link
download here!


MVC4 Registration Form with Client and Server Side Validation in mvc4






Description:-

            In this Example we Explain that How to Create Registration Form with Client and Server side Validation in MVC4.Generally in which we include all control validation like Email validation,phone number validation,password validation,DropdownList validation and CheckBox validation.  

We all know that  Registration form is a common form and used in Every Application , so that reason I want to  demonstrate the basic validation in mvc4 webform. 

There are number of step to devlop the Registration form with Validation are as follows:

First in Home controller write the code for Bind the DropdownList of the Country and state just copy the below code and paste it.

Example for Insert,Update,Delete without Refreshing the webpage CRUD operation without refreshing the page using Json jquery

How to Bind Dynamic data in Ajax Accordion Control Bind data from database in Accordion control

to Download Complete Example click below Download link
download here!


This entry was posted in :