Wednesday, 28 December 2011

Simple Javascript Ajax Example


<html>
<head>
<title>Simple Ajax Exampletitle>

<script language="Javascript">
function xmlhttpPost(strURL) {
var xmlHttpReq = false;
var self = this;
// Mozilla/Safari
if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('POST', strURL, true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) {
updatepage(self.xmlHttpReq.responseText);
}
}
self.xmlHttpReq.send(getquerystring());
}

function getquerystring() {
var form     = document.forms['f1'];
var word = form.word.value;
qstr = 'w=' + escape(word);  // NOTE: no '?' before querystring
return qstr;
}

function updatepage(str){
document.getElementById("result").innerHTML = str;
}
script>

head>
<body>
<form name="f1">
<p>
word:
<input name="word"type="text">
<input value="Go"type="button"onclick='JavaScript:xmlhttpPost("WebFrmforTest.aspx")'>p>
<div id="result">
div>
form>
body>
html>

Tuesday, 20 December 2011

Scrollable GridView With Fixed Headers Asp.Net


 Their is two way to show Headers

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

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>Untitled Pagetitle>
<style type="text/css">
.fixedHeader
{
font-weight: bold;
position: relative;
background-color: #336699;
color: #ffffff;
height: 20px;
}
style>
head>
<body>
<form id="form1"runat="server">
<div style="position: relative">
<table>
<tr>
<td>
First way to show header  
td>
tr>
<tr>
<td>
<asp:Panel ID="Panel1" runat="server"Width="644px"ScrollBars="Vertical">
<asp:GridView ID="GridView1"runat="server"AutoGenerateColumns="false"ShowHeader="true"
Width="636px" Height="208px">
<Columns>
<asp:TemplateField HeaderText="POP_Name"InsertVisible="true">
<ItemTemplate>
<asp:Label ID="Label1" runat="server"Text='<%# Eval("POP_Name") %>'>asp:Label>
ItemTemplate>
asp:TemplateField>
<asp:TemplateField HeaderText="State">
<ItemTemplate>
<asp:Label ID="Label11"runat="server"Text='<%# Eval("State") %>'>asp:Label>
ItemTemplate>
asp:TemplateField>
<asp:TemplateField HeaderText="City">
<ItemTemplate>
<asp:Label ID="Label111"runat="server"Text='<%# Eval("City") %>'>asp:Label>
ItemTemplate>
asp:TemplateField>
Columns>
<HeaderStyle CssClass="fixedHeader" />

asp:GridView>
asp:Panel>
td>
tr>
<tr>
<td>
second way to show header  
td>
tr>
<tr>
<td>
<table>
<tr>
<td>
<table style="border-width: 0px; width: 100%; border-collapse: collapse; background-color: Black;
color: White;" cellspacing="0"border="1">
<tr>
<td align="center"width="13%">
<b>POP_Nameb>
td>
<td align="center"width="13%">
<b>Stateb>
td>
<td align="center"width="10%">
<b>Cityb>
td>
tr>
table>
td>
tr>
<tr>
<td>
<asp:Panel ID="Panel2" runat="server"Width="100%"ScrollBars="Vertical">
<asp:GridView ID="GridView2"runat="server"AutoGenerateColumns="false"ShowHeader="false"
Width="499px" Height="99px">
<Columns>
<asp:TemplateField HeaderText="POP_Name"InsertVisible="true">
<ItemTemplate>
<asp:Label ID="Label1" runat="server"Text='<%# Eval("POP_Name") %>'>asp:Label>
ItemTemplate>
<HeaderStyle Width="20%"HorizontalAlign="Center"/>
asp:TemplateField>
<asp:TemplateField HeaderText="State">
<ItemTemplate>
<asp:Label ID="Label11"runat="server"Text='<%# Eval("State") %>'>asp:Label>
ItemTemplate>
<HeaderStyle Width="20%"HorizontalAlign="Center"/>
asp:TemplateField>
<asp:TemplateField HeaderText="City">
<ItemTemplate>
<asp:Label ID="Label111"runat="server"Text='<%# Eval("City") %>'>asp:Label>
ItemTemplate>
<HeaderStyle Width="10%"HorizontalAlign="Center"/>
asp:TemplateField>
Columns>
asp:GridView>
asp:Panel>
td>
tr>
table>
td>
tr>
<tr>
<td>

td>
tr>
table>
div>
form>
body>
html>

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Powered by Blogger