Posts

Showing posts from July, 2011

Advertisement.

TransHimalaya.in

Everest Helicopter Tour for a day

Book exciting packages at www.transhimalaya.in

Calling and get data ASP.NET AJAX Web Services with jQuery

Addition to basics http://vinodkotiya.blogspot.com/2011/07/calling-aspnet-ajax-web-services-with.html

Calling and Get data ASP.NET AJAX Web Services with jQueryImportant check required: 1. Use JQuery script in head tag   <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
2. To get webservice responce in JSON format use following tag <ScriptMethod(ResponseFormat:=ResponseFormat.Json)>
3.  To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. <System.Web.Script.Services.ScriptService()> _
If you do not include this line in webservice.. you may got internal server error 500...

1. Here will be the web service in App_code folder
Imports System.Web Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.Web.Script.Services Imports System.Web.Script.Serialization
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line…

Calling ASP.NET AJAX Web Services with jQuery

Calling ASP.NET AJAX Web Services with jQueryImportant check required: 1. Use JQuery script in head tag   <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
2. To get webservice responce in JSON format use following tag <ScriptMethod(ResponseFormat:=ResponseFormat.Json)>
3.  To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. <System.Web.Script.Services.ScriptService()> _
If you do not include this line in webservice.. you may got internal server error 500...

1. Here will be the web service in App_code folder
Imports System.Web Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.Web.Script.Services Imports System.Web.Script.Serialization
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. <System.Web.Script.Services.ScriptService()> _ <WebService(Namespace:="http://tempuri.org/")>…

Lambda Expressions Basics

loading external page in div tag with JQuery asp.net

loading external page in JQuery asp.net

              <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>

<!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 src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        // Load the gridview data
        $.ajax({ url: "test.htm",
            cache: false,
            success: function (data)
            { $("div#divExtData").html(data); }
        });



    </script>
</head>
<body>
    <form id="form1" runat="server">


    &l…

ASP.NET Caching Basics

ASP.NET Caching Basics


1st method  on top of aspx page
< %@OutputCacheDuration="10"VaryByParam="None"%>  cache the page . Use substitution control to work with it for performing caching with other web control.
2nd method
Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick




If Cache("vin") Is Nothing Then


Cache.Insert("vin", "Vinod Kotiya " & Now.ToString, Nothing, DateTime.Now.AddSeconds(10.0), TimeSpan.Zero)


Response.Write("creating cache")


Else


Response.Write(Cache("vin").ToString)


End If


End Sub


The Add and Insert methods have the same signature, but there are subtle differences between them. First, calling the Add method returns an object that represents the cached item, while calling Insert does not. Second, their behavior is different if you call these methods and add an item to the Cache that is already stored there. The Insert method replaces the item, while the A…

ASP.NET Security and Authentication.

Add following in web.config File


       <authentication mode="Forms">
      <forms name="f" defaultUrl="default.aspx" loginUrl = "login.aspx" path="/" protection="All">
        <credentials passwordFormat="Clear" >
          <user name="vin" password="1"/>
          <user name="pinx" password="123"/>

        </credentials>

      </forms>
    </authentication>

    <authorization>
      <allow users="vin"/>
      <deny users="pinx"/>
    </authorization>




have 2 page default.aspx and login.aspx
In login.aspt have 2 textbox and 1 button. vb code is:


ProtectedSub Button1_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles Button1.Click If FormsAuthentication.Authenticate(TextBox1.Text, TextBox2.Text) Then FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, False) Else Response.Write("…

ASP.net4.0 Chart Control

Image
Here is a sample Code
1 ASP.net4.0 Chart Control

<body>
    <form id="form1" runat="server">
    <div>
<asp:chart ID="Chart1" runat="server">
<Series >
<asp:Series Name="Championships" YValueType="Int32" ChartType="Column" ChartArea="vinChartArea">

           <Points>
            <asp:DataPoint AxisLabel="India" YValues="17" /> 
            <asp:DataPoint AxisLabel="Pak" YValues="6" /> 
            <asp:DataPoint AxisLabel="USA" YValues="12" /> 
           </Points>


     </asp:Series>
  </Series>
<ChartAreas>
   <asp:ChartArea Name="vinChartArea"></asp:ChartArea></ChartAreas>
</asp:chart>    
    </div>
    </form>
</body>


Here is the Output


2.Creating Chart Programmatically


aspx code with different look.



<body>
    <form id=&qu…

ASP.Net State Management

State Management
1.Hidden Tags
2.Request variable
3.Cookies
4.URL Rewriting  default.aspx?session= Session.SessionID
5.Session Tracking : match  Session.SessionID

Cookies: If enabled in browser then work Eg:


ProtectedSub Button1_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles Button1.Click Dim ck AsNew HttpCookie("myCookie", "vinod") Dim d AsNewDate         d.AddDays(1)         ck.Expires = d 'persist for 1 day         Response.Cookies.Add(ck)         Response.Redirect("cookie2.aspx") EndSub

In cookies2.aspx access it like this:
ProtectedSub Page_Load(ByVal sender AsObject, ByVal e As System.EventArgs) HandlesMe.Load IfNot Request.Cookies.Item("myCookie") IsNothingThen             Response.Write(Request.Cookies.Item("myCookie").Name)             Response.Write(Request.Cookies.Item("myCookie").Value)             Response.Write(Request.Cookies.Item("myCookie").Path) EndIf

Google+ Followers