Search This Blog

Thursday, October 18, 2012

What is JQuery ??? How to use it with Asp.net???

I think you all have to know little bit about the new invention in Technology.or How to use that with the Asp.net.

"JQuery is a cross browser JavaScript library that helps to traverse through HTML elements, event handling, effects(animation) and Ajax interactions."

It is very easy to learn and implement features in out application with the help of JQuery.

Here is Sample Example is given related to it.

Add Script tag into .aspx File for using JQuery on to the Webpage.


<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js">  
</script>

OR aspx.cs File 

protected override void Render(HtmlTextWriter writer)
{
this.Page.ClientScript.RegisterClientScriptInclude("jQuery", "http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js");
base.Render(writer);
}

e.g. Display "Hi, Hitesh!" message on the webpage.

.aspx file : 
        
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head runat="server">
            
            <script type="text/javascript">
            function hi()
            {
                $("#divSample").append("Hi, Hitesh!");
            }
            </script>

        </head>
        <body>
            <form id="form1" runat="server">
                <div id="divSample">
                </div>
            </form>
        </body>
        </html>
        
And Aspx.cs File
            
protected override void Render(HtmlTextWriter writer)
 {
 this.Page.ClientScript.RegisterClientScriptInclude("jQuery", "http://ajax.google  apis.com/ajax/libs/jquery/1.2.6/jquery.min.js");
 this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "startup", "<s  cript type=\"text/javascript\">hi();</script>");
 base.Render(writer);
}




1 comment:

  1. I want something new implementation with the combination of asp.net and jquery.

    ReplyDelete