|
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SampleAjax.aspx.cs" Inherits="SampleJSONWeb.SampleAjax" %>
<!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 id="Head1" runat="server">
<title>Untitled Page</title>
<link type="text/css" href='Scripts/jquery-ui-1.8.11.custom.css' rel="stylesheet" />
<script type="text/javascript" src='<%= this.ResolveUrl("~/Scripts/jquery-1.5.2.min.js")%>' ></script>
<script type="text/javascript" src='<%= this.ResolveUrl("~/Scripts/jquery-ui-1.8.11.custom.min.js")%>' ></script>
<script type="text/javascript" src='<%= this.ResolveUrl("~/Scripts/sample_ajax.js")%>' ></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<script type="text/javascript">
<% if (SampleJSONWeb.ConfigurationData.DebugMode){ %>
ajax.setDebugMode();
<%} %>
$(document).ready(function ()
{
$("#<%= customerDropDown.ClientID %>").change(function ()
{
var customerTypeId = $('#<%= customerDropDown.ClientID %>').val();
ajax.get('<%= this.ResolveUrl("~/LoadCustomerDescriptions.ashx")%>',
{ 'customerTypeId': customerTypeId },
'CustomerDescriptionsLoader',
function (response)
{
$('#<%= customerDescriptionDropDown.ClientID %> option').remove();
for (var i = 0; i < response.Data.length; i++)
{
$('#<%= customerDescriptionDropDown.ClientID %>').append(getOptionString(response.Data[i]));
}
}
);
});
function getOptionString(dataElement)
{
return "<option value='"+dataElement.Id+"' >"+dataElement.Name+"</option>";
}
});
</script>
<table>
<td>
Customer:
</td>
<td>
<asp:DropDownList ID="customerDropDown" runat="server" Width="200px" >
<asp:ListItem></asp:ListItem>
<asp:ListItem>Customer1</asp:ListItem>
<asp:ListItem>Customer2</asp:ListItem>
<asp:ListItem>Customer3</asp:ListItem>
</asp:DropDownList>
<img id="CustomerDescriptionsLoader" style="display:none" src="<%= this.ResolveUrl("~/Images/ajax-loader.gif") %>" alt="loading" />
</td>
<td>
Customer Description:
</td>
<td>
<asp:DropDownList ID="customerDescriptionDropDown" runat="server" Width="200px" >
</asp:DropDownList>
</td>
</table>
</div>
</form>
</body>
</html>
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Pubudu Kasakara is working as Solution Architect in Singapore. He has more than 11 years of professional involvement in the IT industry. Worked in successful projects involving mainly the Service Oriented Application by contributing to all requirements gathering, design and implementation phases. He is having experience with SOA applications development, Microsoft .NET, BizTalk, He is member of Charted It professional in UK.
Solution Architect
http://www.kasakara.com