Archive

Archive for January, 2010

Export To Excel Inside An Update Panel in Asp.net

January 27, 2010 2 comments

When using export to excel inside update panel, it will popup an error like “pagerequestmanagerparsererrorexception” .

The actual problem is with Response.write, as it tries to update only certain part of the page asynchronously.

This can be solved in following ways:

1) Adding trigger :

<Triggers>
<asp:PostBackTrigger ControlID=”btn_ExpertToExcel” />
</Triggers>

2) Placing button outside the update panel



Refresh Content in UpdatePanel using Asp.net Ajax Timer Control

January 19, 2010 1 comment

Lets say we have a requirement where we have a label control and we have assigned date time to its text, and in every 5 seconds we want to update the time, over there we need to place the label control inside the update panel and use a timer control to update its content.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Update Panel and Timer</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <asp:Timer runat="server" id="UpdateTimer" interval="5000"
          ontick="UpdateTimer_Tick" />
        <asp:UpdatePanel runat="server" id="TimedPanel" updatemode="Conditional">
            <Triggers>
                <asp:AsyncPostBackTrigger controlid="UpdateTimer"
                  eventname="Tick" />
            </Triggers>
            <ContentTemplate>
                <asp:Label runat="server" id="lbldatetime" />
            </ContentTemplate>
        </asp:UpdatePanel>
    </form>
</body>
</html>

In the codebehind:

protected void UpdateTimer_Tick(object sender, EventArgs e)
{  
lbldatetime.Text = DateTime.Now.ToString();
}

Checkbox Selection of Multiple Columns in Gridview In Asp.net

January 18, 2010 Leave a comment

Many times we have to implement a scenario where we have multiple columns in gridview. Selection of checkboxes in each column in gridview. here is a complete solution for it, you can also download the code:

http://www.highoncoding.com/Articles/508_Solving_CheckAll_Problems_for_GridView_with_CheckBoxes_in_Multiple_Columns.aspx

Toggle Div Using Jquery

January 12, 2010 Leave a comment

Show/Hide div using jquery:

<html>
<head>
     <script language="javascript" src="js/jquery.js"></script>
     <script language="javascript">
     $(document).ready(function() {
          $('#lnkbtn').click(function() {
               if ($('#divContent').is(":hidden"))
               {
                    $('#divContent').slideDown("slow");
                    document.getElementById('lnkbtn').innerText = 'Hide Div';
               } else {
                    $('#divContent').slideUp("slow");
                    document.getElementById('lnkbtn').innerText = 'Show Div';
               }
          });
     });
     </script>
</head>
<body>
     <a href="javascript:void(0);" id="lnkbtn">Hide Div</a>
     <div id="divContent">
          Content<br>
          comes<br>
          here
     </div>
</body>
</html>

Other jquery effects can be found at :
http://docs.jquery.com/Effects