Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 604661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:03:44+00:00 2026-05-13T17:03:44+00:00

I have HTML table on the ASP.NET MVC View page. Now I have to

  • 0

I have HTML table on the ASP.NET MVC View page. Now I have to export this table to Excel.

(1) I have used partial view (Inquiries.ascx) to display the table data from database (using LINQ to Entity)
(2) I also have used UITableFilter plugin to filter the records (Ex: http://gregweber.info/projects/demo/flavorzoom.html )

(3) At any point of time, I have to filter the visible records to Excel.

Appreciate your responses.

Thanks

Rita

Here is my View:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Mvc.Master" Inherits="System.Web.Mvc.ViewPage" %>


<asp:Content ID="Content2" ContentPlaceHolderID="cphHead" runat="server">
<script src="../../Scripts/jquery.tablesorter.js" type="text/javascript"></script>
     <script src="../../Scripts/jquery.uitablefilter.js" type="text/javascript"></script>

<script type="text/javascript">
 //Load Partial View
$('#MyInquiries').load('/Home/Inquiries');

// To Apply Filter Expression using uiTableFilter plugin
            $("#searchName").keyup(function() {
                $.uiTableFilter($("#tblRefRequests"), this.value);
                $("#tblRefRequests").tablesorter({ widthFixed: true, widgets: ['zebra'] });
            });


//Export the HTML table contents to Excel
      $('#export').click(function() {
//Code goes here

});
</script>
</asp:Content>

//Main Content
<asp:Content ID="Content1" ContentPlaceHolderID="cphContent" runat="server">
<h2 class="pageName">View All Inquiries</h2>
<input type="submit" value="Export to Excel" id="export" />
<div id='MyInquiries'></div>
</asp:Content>

Strongly Typed Partial view user control (Inquiries.ascx) to generate table:

<table>
    <tr><td valign ="middle">Filter Expression: <%= Html.TextBox("searchName")%></td></tr>
    </table>
    <table id="tblRefRequests" >
    <thead>
        <tr>
            <th>Tx_ID</th>
            <th>TX Date</th>
            <th>Name</th>
            <th>Email Address </th>
            <th>Products</th>
            <th>Document Name</th>
        </tr>
</thead>

<tbody>
    <% foreach (var item in Model) { %>
        <tr>
            <td visible =false><%= item.RequestID %></td>
            <td><%= String.Format("{0:d}", item.RequestDate) %></td>
            <td><%= item.CustomerName %></td>
            <td><%= Html.Encode(item.Email) %></td>
            <td><%= item.ProductName %></td>
            <td><%= Html.Encode(item.DocDescription)%></td>
        </tr>
    <% } %>
</tbody>
    </table>

Here is my Controller code to load the Inquiries partial view:

[HttpGet]
        public PartialViewResult Inquiries()
        {
var model = from i in myEntity.Inquiries
  where i.User_Id == 5
                        orderby i.TX_Id descending
                        select new {
                            RequestID = i.TX_Id,
                            CustomerName = i.CustomerMaster.FirstName,
                            RequestDate = i.RequestDate,
                            Email = i.CustomerMaster.MS_Id,
                            DocDescription = i.Document.Description,
                            ProductName = i.Product.Name
                        };
            return PartialView(model);
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T17:03:44+00:00Added an answer on May 13, 2026 at 5:03 pm

    Try the jQuery plugin: table2csv. Use the argument, delivery:’value’, to return the csv as a string.

    Here is an implementation:

    1. Add a regular html input button and a .NET HiddenField to the page
    2. Add an onclick event to that button called “Export”
    3. Create a javascript function, Export, that stores the return value of table2CSV() into the hidden field, and posts back.
    4. The server receives the hiddenfield post data (the csv as a string)
    5. The server outputs the string to the browser as a csv file

    .

    // javascript  
    function Export()  
    {    
        $('#yourHiddenFieldId').val() = $('#yourTable').table2CSV({delivery:'value'});  
        __doPostBack('#yourExportBtnId', '');  
    }
    
    // c#  
    if(Page.IsPostBack)  
    {
        if(!String.IsNullOrEmpty(Request.Form[yourHiddenField.UniqueId]))  
        {  
            Response.Clear();  
            Response.ContentType = "text/csv";  
            Response.AddHeader("Content-Disposition", "attachment; filename=TheReport.csv");  
            Response.Flush();  
            Response.Write(Request.Form[yourHiddenField.UniqueID]);  
            Response.End();  
        }  
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this part in asp.net MVC 3 view: <tr> <td>@Html.LabelFor(x => x.DateOfBirth, new
i have an html table in my asp.net mvc view an i am running
I have an ASP.NET page and I am generating an HTML table in my
If I have code inside an ASP.NET MVC view that looks like this: <%
i have an asp.net mvc view where the top of the page is a
I have the following HTML generated by an ASP.NET repeater: <table> <tr> <td><input type=hidden
So I have a simple voting feature on my asp.net mvc page. My index
We have a ASP.NET MVC 3 application that uses unobtrusive jQuery validation. The page
How submit list View in ASP.NET MVC. List View dont have input type=submit value=Save
I am trying to add a jqGrid to a ASP.NET MVC3 partial view. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.