Translate

Friday, 31 July 2015

Concate Sql Query in c#

  The  Below query is concate in c#
When a long query we write we impliments this
Solution
-----------
 protected void Button1_Click(object sender, EventArgs e)
    {

        string Name = "Pabitra";
        // string Query = "insert into tblEmployee ( id, name ) values( " + 4 + ",'" + Name + "' )";
        string Query = "insert into tblEmployee " +
            " (        " +
            " id,      " +
            " name     " +
            " )        " +

            " values(  " +
            "" + 4 + "," +
            "'" + Name + "' " +
            " )";
        Response.Write(Query);
    }

Sunday, 19 July 2015

Wednesday, 8 July 2015

Key Down Events and Key press Events

Key Down Events
-----------------


<script type="text/javascript">
        $(document).ready(function () {
            $("#<%= txtcontactno.ClientID%>").keydown(function (e) {
                if (e.shiftKey)
                    e.preventDefault();
                else {
                    var nKeyCode = e.keyCode;
                    //Ignore Backspace and Tab keys      
                    if (nKeyCode == 8 || nKeyCode == 9)
                        return;
                    if (nKeyCode < 95) {
                        if (nKeyCode < 48 || nKeyCode > 57)
                            e.preventDefault();
                    }
                    else {
                        if (nKeyCode < 96 || nKeyCode > 105)
                            e.preventDefault();
                    }
                }
            });
        });
    </script>



Key press Events
-----------------
 <script type="text/javascript">

        $(document).ready(function () {
            //called when key is pressed in textbox
            $('#<%=txtcontactno.ClientID%>').keypress(function (e) {
                alert('hello');
                //if the letter is not digit then display error and don't type anything
                if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
                    //display error message
                    //  alert('Please Enter ');
                    //  $("#errmsg").html("Digits Only").show().fadeOut("slow");
                    return false;
                }
            });
        });

    </script>
------------

Monday, 6 July 2015

sql alter drop rename column in the table

To add a column in a table, use the following syntax:
------------------------------
ALTER TABLE table_name
ADD column_name datatype

-----------------------------
To delete a column in a table, use the following syntax (notice that some database systems don't
allow deleting a column):
--------------------------------------
ALTER TABLE table_name
DROP COLUMN column_name
-----------------------------


To change the data type of a column in a table, use the following syntax:
--------------------------------------------
ALTER TABLE table_name
ALTER COLUMN column_name datatype


----------------------------------
To rename Column Name
-------------------------
EXEC sp_RENAME 'table_name.old_name', 'new_name', 'COLUMN'

Thursday, 18 June 2015

get ip address in c#

 //using System.Net;
        string hostName = Dns.GetHostName(); // Retrive the Name of HOST  
        string myIP = Dns.GetHostByName(hostName).AddressList[0].ToString();
        Response.Write("My IP Address is :" + myIP);



or
-------
string ip_address = Convert.ToString(HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]);
   Response.Write("My IP Address is :" + ip_address);  

C#- different type of alert message in code behind

 string Message = "Pabitra you as Microsoft Employee !";
         ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Pabitra you as Microsoft Employee !');", true);
         ClientScript.RegisterStartupScript(GetType(), "alert", "alert('" + Message + "');", true);

         ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Pabitra you as Microsoft Employee !');", true);
         ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + Message + "');", true);

         Response.Write(@"<script language='javascript'>alert('Pabitra you as Microsoft Employee ! ')</script>");
         Response.Write(@"<script language='javascript'>alert('"+Message+"')</script>");

         Page.ClientScript.RegisterStartupScript(Page.GetType(), "MessageBox", "<script language='javascript'>alert('Pabitra you as Microsoft Employee !');</script>");
         Page.ClientScript.RegisterStartupScript(Page.GetType(),"MessageBox","<script language='javascript'>alert('" + Message + "');</script>");

         ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "ClientScript", "alert('Pabitra you as Microsoft Employee !')", true);
         ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "ClientScript", "alert('" + Message + "')", true);
        ////////////////
ClientScript.RegisterStartupScript(this.GetType(), "Email", "<script>GetEmail();</script>");
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmessage", "javascript:alert('Please Enter Data')", true);

         ClientScript.RegisterClientScriptBlock(GetType(), "Email", "GetEmail();", true);
        //In Html Page
        <head>
        <script type="text/javascript" language="javascript">
         function GetEmail() {
             alert('hi');
         }
        </script>
    </head>
    ///////////////////////////