Friday, 25 January 2013

To Find Created Date and Modified Date in StoredProcedure in SQL


SELECT create_date,modify_date,name FROM sys.objects where type = 'p'

ORDER BY modify_date DESC

To Overcome Length Problem of Textarea in Asp.net

<asp:TextBox runat="server" style="overflow:hidden;" ID="txtAreaCommets" Font-Size="11px" TextMode="MultiLine" Text='<%# Bind("ProcessedRemarks") %>' Rows="2" Width="99.5%" oncopy="return false" oncut="return false" onpaste="return false" onkeypress="if (this.value.length > 250) { return false; }"></asp:TextBox>

Sunday, 2 December 2012

Freeze column in html table

<html>
<head>
    <title></title>
    <style>
        table
        {
            font-family: verdana;
        }
        div#AdjResultsDiv
        {
            width: 200px;
            height: 200px;
            overflow-x: scroll;
            position: relative;
            font-family: verdana;
        }
        div#AdjResultsDiv th
        {
            background-color: navy;
            font-family: verdana;
            color: white;
            position: relative;
            cursor: default;
            top: expression(document.getElementById("AdjResultsDiv").scrollTop-2); /*IE5+ only*/
            z-index: 10;
        }
        td.locked, th.locked
        {
            font-family: verdana;
            color: white;
            background-color: navy;
            position: relative;
            cursor: default;
            left: expression(document.getElementById("AdjResultsDiv").scrollLeft-2); /*IE5+ only*/
        }
        div#AdjResultsDiv th.locked, div#AdjResultsDiv td.normal
        {
            z-index: 99;
        }
    </style>
</head>
<body>
    <div id="AdjResultsDiv">
        <table border="1" style="left: 1px; top: 155px; height: 1px;" cellpadding="0px" cellspacing="0px"
            align="center">
            <tr>
                <td class="locked" style="font-weight: bold; font-size: 12px; background-color: #69a6d0;
                    font-size: 12px; color: #ffffff; height: 19px; color: White;" width="100px" align="center">
                    Colunm1
                </td>
                <td style="font-weight: bold; font-size: 12px; color: #ffffff; height: 19px; background-color: #69a6d0;
                    color: White;" width="100px" align="center">
                    Colunm2
                </td>
                <td style="font-weight: bold; font-size: 12px; color: #ffffff; height: 19px; background-color: #69a6d0;
                    color: White;" width="250px" align="center">
                    Colunm3
                </td>
                <td style="font-weight: bold; font-size: 12px; color: #ffffff; height: 19px; background-color: #69a6d0;
                    color: White;" width="100px" align="center">
                    Colunm4
                </td>
                <td style="font-weight: bold; font-size: 12px; color: #ffffff; height: 19px; background-color: #69a6d0;
                    color: White;" width="100px" align="center">
                    Colunm5
                </td>
            </tr>
            <tr>
                <td class="locked" style="font-weight: bold; font-size: 12px; background-color: #69a6d0;
                    font-size: 12px; color: #ffffff; height: 19px; color: White;" width="100px" align="center">
                    Colunm1
                </td>
                <td style="font-weight: bold; font-size: 12px; color: #ffffff; height: 19px; background-color: #69a6d0;
                    color: White;" width="100px" align="center">
                    Colunm2
                </td>
                <td style="font-weight: bold; font-size: 12px; color: #ffffff; height: 19px; background-color: #69a6d0;
                    color: White;" width="250px" align="center">
                    Colunm3
                </td>
                <td style="font-weight: bold; font-size: 12px; color: #ffffff; height: 19px; background-color: #69a6d0;
                    color: White;" width="100px" align="center">
                    Colunm4
                </td>
                <td style="font-weight: bold; font-size: 12px; color: #ffffff; height: 19px; background-color: #69a6d0;
                    color: White;" width="100px" align="center">
                    Colunm5
                </td>
            </tr>
            <tr>
                <td class="locked" style="font-weight: bold; font-size: 12px; background-color: #69a6d0;
                    font-size: 12px; color: #ffffff; height: 19px; color: White;" width="100px" align="center">
                    Colunm1
                </td>
                <td style="font-weight: bold; font-size: 12px; color: #ffffff; height: 19px; background-color: #69a6d0;
                    color: White;" width="100px" align="center">
                    Colunm2
                </td>
                <td style="font-weight: bold; font-size: 12px; color: #ffffff; height: 19px; background-color: #69a6d0;
                    color: White;" width="250px" align="center">
                    Colunm3
                </td>
                <td style="font-weight: bold; font-size: 12px; color: #ffffff; height: 19px; background-color: #69a6d0;
                    color: White;" width="100px" align="center">
                    Colunm4
                </td>
                <td style="font-weight: bold; font-size: 12px; color: #ffffff; height: 19px; background-color: #69a6d0;
                    color: White;" width="100px" align="center">
                    Colunm5
                </td>
            </tr>
            <tr>
                <td class="locked" style="font-weight: bold; font-size: 12px; background-color: #69a6d0;
                    font-size: 12px; color: #ffffff; height: 19px; color: White;" width="100px" align="center">
                    Colunm1
                </td>
                <td style="font-weight: bold; font-size: 12px; color: #ffffff; height: 19px; background-color: #69a6d0;
                    color: White;" width="100px" align="center">
                    Colunm2
                </td>
                <td style="font-weight: bold; font-size: 12px; color: #ffffff; height: 19px; background-color: #69a6d0;
                    color: White;" width="250px" align="center">
                    Colunm3
                </td>
                <td style="font-weight: bold; font-size: 12px; color: #ffffff; height: 19px; background-color: #69a6d0;
                    color: White;" width="100px" align="center">
                    Colunm4
                </td>
                <td style="font-weight: bold; font-size: 12px; color: #ffffff; height: 19px; background-color: #69a6d0;
                    color: White;" width="100px" align="center">
                    Colunm5
                </td>
            </tr>
            <tr>
                <td class="locked" style="font-weight: bold; font-size: 12px; background-color: #69a6d0;
                    font-size: 12px; color: #ffffff; height: 19px; color: White;" width="100px" align="center">
                    Colunm1
                </td>
                <td style="font-weight: bold; font-size: 12px; color: #ffffff; height: 19px; background-color: #69a6d0;
                    color: White;" width="100px" align="center">
                    Colunm2
                </td>
                <td style="font-weight: bold; font-size: 12px; color: #ffffff; height: 19px; background-color: #69a6d0;
                    color: White;" width="250px" align="center">
                    Colunm3
                </td>
                <td style="font-weight: bold; font-size: 12px; color: #ffffff; height: 19px; background-color: #69a6d0;
                    color: White;" width="100px" align="center">
                    Colunm4
                </td>
                <td style="font-weight: bold; font-size: 12px; color: #ffffff; height: 19px; background-color: #69a6d0;
                    color: White;" width="100px" align="center">
                    Colunm5
                </td>
            </tr>
            <tr>
                <td class="locked" style="font-weight: bold; font-size: 12px; background-color: #69a6d0;
                    font-size: 12px; color: #ffffff; height: 19px; color: White;" width="100px" align="center">
                    Colunm1
                </td>
                <td style="font-weight: bold; font-size: 12px; color: #ffffff; height: 19px; background-color: #69a6d0;
                    color: White;" width="100px" align="center">
                    Colunm2
                </td>
                <td style="font-weight: bold; font-size: 12px; color: #ffffff; height: 19px; background-color: #69a6d0;
                    color: White;" width="250px" align="center">
                    Colunm3
                </td>
                <td style="font-weight: bold; font-size: 12px; color: #ffffff; height: 19px; background-color: #69a6d0;
                    color: White;" width="100px" align="center">
                    Colunm4
                </td>
                <td style="font-weight: bold; font-size: 12px; color: #ffffff; height: 19px; background-color: #69a6d0;
                    color: White;" width="100px" align="center">
                    Colunm5
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>

write error message in Notepad using C#


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Net.Mail;
using System.Net;

public partial class ErrorMessageInNotePad : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnCreateError_Click(object sender, EventArgs e)
    {
        try
        {
            throw new System.ArgumentException("Sajil Created the ErrorMessage!!!");
        }
        catch (Exception ex)
        {
//HERE YOU CAN USE PAGE NAME,FILE NAME,MODULE NAME OR FUNCTION                                               NAME TO   IDENTIFY THE ERROR SPOT  AND YOU CAN ALSO MAKE THESE CODE AS SAPARATE FUNCTION  AND USE IN CACTH BLOCK.

            StreamWriter sw = new StreamWriter(Server.MapPath("ErrorNotepad") + "\\ErrorList.txt", true);
            sw.WriteLine("Error occurred at", DateTime.Now.ToString());
            sw.WriteLine(ex.Message, DateTime.Now.ToString());
            sw.Dispose();
//CODE FOR SEND MAIL THAT NOTEPAD
            MailMessage newmsg;
            MailAddress mailfrom = new MailAddress("xxxxx.com");
            MailAddress mailto = new MailAddress("xxxxx.com");
            newmsg = new MailMessage(mailfrom, mailto);

            newmsg.Body ="You Have Error Message!!!";
         
            Attachment att = new Attachment(Server.MapPath("ErrorNotepad") + "\\ErrorList.txt");

            newmsg.Attachments.Add(att);
            SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
            smtp.UseDefaultCredentials = false;
            smtp.Credentials = new NetworkCredential("xxxxx", "xxxxx");
            smtp.EnableSsl = true;
            smtp.Send(newmsg);
           

        }
    }
}
POST COMMENT IF ITS USEFULL,HAPPY CODING.....

Wednesday, 28 November 2012

how to get previous page value in asp.net

In First Page
--------------
   protected void btn_Click(object sender, EventArgs e)
    {
           //hnd is the hidden field
            hdn.Value = "sajil";
            Server.Transfer("SecondPage.aspx", true);
     }
In second Page
--------------
 You can get this hdn value in the second page using the code below

   protected void Page_Load(object sender, EventArgs e)
  {
    HiddenField txt = (HiddenField)Page.PreviousPage.FindControl("hdn");
    Response.Write(txt.Value);
  }

Saturday, 24 November 2012

printing problem

getting paper wasted in top 

ref:secont picture paper get wasted like this

Monday, 19 November 2012

Highlight Gridview Row When CheckBox is Checked using javascript


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="gridviewCheckbox_javascript.aspx.cs"
    Inherits="gridviewCheckbox_javascript" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function CheckClick(obj) {
            //Get the Row based on checkbox order
            var row = obj.parentNode.parentNode;
            if (obj.checked) {
                //If checked change color to Red
                row.style.backgroundColor = "Red";
            }
               else {
                row.style.backgroundColor = "white";
            }
           //Get the reference of GridView
            var GridView = row.parentNode;

            //Get all input elements in Gridview
            var inputList = GridView.getElementsByTagName("input");

            for (var i = 0; i < inputList.length; i++) {
                //The First element is the Header Checkbox
                var headerCheckBox = inputList[0];

                //Based on all or none checkboxes
                //are checked check/uncheck Header Checkbox
                var checked = true;
                if (inputList[i].type == "checkbox" && inputList[i] != headerCheckBox) {
                    if (!inputList[i].checked) {
                        checked = false;
                        break;
                    }
                }
            }
            headerCheckBox.checked = checked;

        }
        function checkAll(objRef) {
            var GridView = objRef.parentNode.parentNode.parentNode;
            var inputList = GridView.getElementsByTagName("input");
            for (var i = 0; i < inputList.length; i++) {
                //Get the Cell To find out ColumnIndex
                var row = inputList[i].parentNode.parentNode;
                if (inputList[i].type == "checkbox" && objRef != inputList[i]) {
                    if (objRef.checked) {
                        row.style.backgroundColor = "Red";
                        inputList[i].checked = true;
                    }
                    else {
                        row.style.backgroundColor = "white";
                        inputList[i].checked = false;
                    }
                }
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="sm" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel runat="server" ID="up">
            <ContentTemplate>
                <div>
                    <asp:GridView ID="gvBank" runat="server">
                        <HeaderStyle BackColor="#df5015" Font-Bold="true" ForeColor="White" />
                        <Columns>
                            <asp:TemplateField>
                                <HeaderTemplate>
                                    <asp:CheckBox ID="chkHeader" runat="server" onclick="checkAll(this);" />
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <asp:CheckBox ID="chkChild" runat="server" onclick="CheckClick(this)" />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                </div>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>