Autoextender.js File Download at Location
Autocomplete.cs File Download at Location
Nice Link : CultureInfo
Wednesday, March 11, 2009
Sunday, February 22, 2009
AJAXToolKit AutoComplete Extender
AJAXToolKit AutoExtender Example 1
Example 2
Example 3
Example 4
Example 5
Example 6
Example 7
Example 8
Embedding images in mails properly
Example 9
Resource
ASPX
<1--function id="collegeteamextender" runat="server" servicepath="ncaa.asmx" servicemethod="getTeamList" minimumprefixlength="1" completionsetcount="10" targetcontrolid="collegeteam">-->
ASMX
namespace AutoComplete
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class ncaa : System.Web.Services.WebService
{
[WebMethod]
public string[] getTeamList(string prefixText, int count)
{
DataSet teams = new DataSet();
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
string sql = "SELECT TOP " + count + " team_name FROM team WHERE team_name LIKE '" + prefixText + "%'";
SqlCommand sqlCmd = new SqlCommand(sql, conn);
conn.Open();
SqlDataAdapter sqlAdpt = new SqlDataAdapter();
sqlAdpt.SelectCommand = sqlCmd;
sqlAdpt.Fill(teams);
string[] teamName = new String[teams.Tables[0].Rows.Count];
int i = 0;
try
{
foreach (DataRow row in teams.Tables[0].Rows)
{
teamName.SetValue(row["team_name"].ToString(), i);
i++;
}
}
catch { }
finally
{
conn.Close();
}
return teamName;
}
}
}
-----------------------
Example 2
Example 3
Example 4
Example 5
Example 6
Example 7
Example 8
Embedding images in mails properly
Example 9
Resource
ASPX
<1--function id="collegeteamextender" runat="server" servicepath="ncaa.asmx" servicemethod="getTeamList" minimumprefixlength="1" completionsetcount="10" targetcontrolid="collegeteam">-->
ASMX
namespace AutoComplete
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class ncaa : System.Web.Services.WebService
{
[WebMethod]
public string[] getTeamList(string prefixText, int count)
{
DataSet teams = new DataSet();
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
string sql = "SELECT TOP " + count + " team_name FROM team WHERE team_name LIKE '" + prefixText + "%'";
SqlCommand sqlCmd = new SqlCommand(sql, conn);
conn.Open();
SqlDataAdapter sqlAdpt = new SqlDataAdapter();
sqlAdpt.SelectCommand = sqlCmd;
sqlAdpt.Fill(teams);
string[] teamName = new String[teams.Tables[0].Rows.Count];
int i = 0;
try
{
foreach (DataRow row in teams.Tables[0].Rows)
{
teamName.SetValue(row["team_name"].ToString(), i);
i++;
}
}
catch { }
finally
{
conn.Close();
}
return teamName;
}
}
}
-----------------------
[WebMethod]
public string[] GetCompletionList(string prefixText, int count)
{
if (count == 0)
{
count = 10;
}
if (prefixText.Equals("xyz"))
{
return new string[0];
}
Random random = new Random();
List<string> items = new List<string>(count);
for (int i = 0; i < class="kwrd">char c1 = (char)random.Next(65, 90);
char c2 = (char)random.Next(97, 122);
char c3 = (char)random.Next(97, 122);
items.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(prefixText + c1 + c2 + c3, i.ToString()));
}
return items.ToArray();
}
AJAX Toolkit Extender IMP
///
/// Create a serialized JSON object representing a text/value pair that can
/// be returned by the webservice.
///
/// Text
/// Value
/// The html markup to be rendered
///serialized JSON object representing the text/value/html tuple
public static string CreateAutoCompleteItem(string text, string value, string markup)
{
return new JavaScriptSerializer().Serialize(new Pair(text, new Pair(value, markup)));
}
Javascript Functions (_setText and _update)
_setText: function(item) {
///
/// Method to set the selected autocomplete option on the textbox
///
///
/// Item to select
///
///
var realItem = item;
var text = null;
do
{
if(realItem._text !== undefined) {
text = realItem._text;
}
else {
realItem = realItem.parentNode;
}
}
while(text == null)
//var text = (item && item.firstChild) ? item.firstChild.nodeValue : null;
this._timer.set_enabled(false);
var element = this.get_element();
var control = element.control;
if (control && control.set_text) {
control.set_text(text);
$common.tryFireEvent(control, "change");
}
else {
element.value = text;
$common.tryFireEvent(element, "change");
}
this.raiseItemSelected(new AjaxControlToolkit.AutoCompleteItemEventArgs(item, text, realItem ? realItem._value : null));
this._currentPrefix = this._currentCompletionWord();
this._hideCompletionList();
},
_update: function(prefixText, completionItems, cacheResults) {
///
/// Method to update the status of the autocomplete behavior
///
///
///
///
///
if (cacheResults && this.get_enableCaching()) {
if (!this._cache) {
this._cache = {};
}
this._cache[prefixText] = completionItems;
}
// If the target control loses focus or
// if the value in textbox has changed before the webservice returned
// completion items we don't need to show popup
if ((!this._textBoxHasFocus) || (prefixText != this._currentCompletionWord())) {
this._hideCompletionList();
return;
}
if (completionItems && completionItems.length) {
this._completionListElement.innerHTML = '';
this._selectIndex = -1;
var _firstChild = null;
var text = null;
var value = null;
var markup = null;
for (var i = 0; i < completionItems.length; i++) {
// Create the item
var itemElement = null;
if (this._completionListElementID) {
// the completion element has been created by the user and li won't necessarily work
itemElement = document.createElement('div');
} else {
itemElement = document.createElement('li');
}
// set the first child if it is null
if( _firstChild == null ){
_firstChild = itemElement;
}
// Get the text/value for the item
try {
var pair = Sys.Serialization.JavaScriptSerializer.deserialize('(' + completionItems[i] + ')');
if(pair && pair.First && pair.Second.First) {
text = pair.First;
value = pair.Second.First;
markup = pair.Second.Second;
}
else if (pair && pair.First) {
// Use the text and value pair returned from the web service
text = pair.First;
value = pair.Second;
markup = null;
} else {
// If the web service only returned a regular string, use it for
// both the text and the value
text = pair;
value = pair;
markup = null;
}
} catch (ex) {
text = completionItems[i];
value = completionItems[i];
markup = null;
}
if(markup == null) {
// Set the text/value for the item
itemElement.appendChild(document.createTextNode(this._getTextWithInsertedWord(text)));
}
else {
var element = document.createElement("div");
element.innerHTML = markup;
itemElement.appendChild(element);
}
itemElement._text = text;
itemElement._value = value;
itemElement.__item = '';
if (this._completionListItemCssClass) {
Sys.UI.DomElement.addCssClass(itemElement, this._completionListItemCssClass);
} else {
var itemElementStyle = itemElement.style;
itemElementStyle.padding = '0px';
itemElementStyle.textAlign = 'left';
itemElementStyle.textOverflow = 'ellipsis';
// workaround for safari since normal colors do not
// show well there.
if (Sys.Browser.agent === Sys.Browser.Safari) {
itemElementStyle.backgroundColor = 'white';
itemElementStyle.color = 'black';
} else {
itemElementStyle.backgroundColor = this._textBackground;
itemElementStyle.color = this._textColor;
}
}
this._completionListElement.appendChild(itemElement);
}
var elementBounds = $common.getBounds(this.get_element());
this._completionListElement.style.width = Math.max(1, elementBounds.width - 2) + 'px';
this._completionListElement.scrollTop = 0;
this.raisePopulated(Sys.EventArgs.Empty);
var eventArgs = new Sys.CancelEventArgs();
this.raiseShowing(eventArgs);
if (!eventArgs.get_cancel()) {
this.showPopup();
// Check if the first Row is to be selected by default and if yes highlight it and updated selectIndex.
if (this._firstRowSelected && (_firstChild != null)) {
this._highlightItem( _firstChild );
this._selectIndex = 0;
}
}
} else {
this._hideCompletionList();
}
},
/// Create a serialized JSON object representing a text/value pair that can
/// be returned by the webservice.
///
/// Text
/// Value
/// The html markup to be rendered
///
public static string CreateAutoCompleteItem(string text, string value, string markup)
{
return new JavaScriptSerializer().Serialize(new Pair(text, new Pair(value, markup)));
}
Javascript Functions (_setText and _update)
_setText: function(item) {
///
/// Method to set the selected autocomplete option on the textbox
///
///
/// Item to select
///
///
var realItem = item;
var text = null;
do
{
if(realItem._text !== undefined) {
text = realItem._text;
}
else {
realItem = realItem.parentNode;
}
}
while(text == null)
//var text = (item && item.firstChild) ? item.firstChild.nodeValue : null;
this._timer.set_enabled(false);
var element = this.get_element();
var control = element.control;
if (control && control.set_text) {
control.set_text(text);
$common.tryFireEvent(control, "change");
}
else {
element.value = text;
$common.tryFireEvent(element, "change");
}
this.raiseItemSelected(new AjaxControlToolkit.AutoCompleteItemEventArgs(item, text, realItem ? realItem._value : null));
this._currentPrefix = this._currentCompletionWord();
this._hideCompletionList();
},
_update: function(prefixText, completionItems, cacheResults) {
///
/// Method to update the status of the autocomplete behavior
///
///
///
///
///
if (cacheResults && this.get_enableCaching()) {
if (!this._cache) {
this._cache = {};
}
this._cache[prefixText] = completionItems;
}
// If the target control loses focus or
// if the value in textbox has changed before the webservice returned
// completion items we don't need to show popup
if ((!this._textBoxHasFocus) || (prefixText != this._currentCompletionWord())) {
this._hideCompletionList();
return;
}
if (completionItems && completionItems.length) {
this._completionListElement.innerHTML = '';
this._selectIndex = -1;
var _firstChild = null;
var text = null;
var value = null;
var markup = null;
for (var i = 0; i < completionItems.length; i++) {
// Create the item
var itemElement = null;
if (this._completionListElementID) {
// the completion element has been created by the user and li won't necessarily work
itemElement = document.createElement('div');
} else {
itemElement = document.createElement('li');
}
// set the first child if it is null
if( _firstChild == null ){
_firstChild = itemElement;
}
// Get the text/value for the item
try {
var pair = Sys.Serialization.JavaScriptSerializer.deserialize('(' + completionItems[i] + ')');
if(pair && pair.First && pair.Second.First) {
text = pair.First;
value = pair.Second.First;
markup = pair.Second.Second;
}
else if (pair && pair.First) {
// Use the text and value pair returned from the web service
text = pair.First;
value = pair.Second;
markup = null;
} else {
// If the web service only returned a regular string, use it for
// both the text and the value
text = pair;
value = pair;
markup = null;
}
} catch (ex) {
text = completionItems[i];
value = completionItems[i];
markup = null;
}
if(markup == null) {
// Set the text/value for the item
itemElement.appendChild(document.createTextNode(this._getTextWithInsertedWord(text)));
}
else {
var element = document.createElement("div");
element.innerHTML = markup;
itemElement.appendChild(element);
}
itemElement._text = text;
itemElement._value = value;
itemElement.__item = '';
if (this._completionListItemCssClass) {
Sys.UI.DomElement.addCssClass(itemElement, this._completionListItemCssClass);
} else {
var itemElementStyle = itemElement.style;
itemElementStyle.padding = '0px';
itemElementStyle.textAlign = 'left';
itemElementStyle.textOverflow = 'ellipsis';
// workaround for safari since normal colors do not
// show well there.
if (Sys.Browser.agent === Sys.Browser.Safari) {
itemElementStyle.backgroundColor = 'white';
itemElementStyle.color = 'black';
} else {
itemElementStyle.backgroundColor = this._textBackground;
itemElementStyle.color = this._textColor;
}
}
this._completionListElement.appendChild(itemElement);
}
var elementBounds = $common.getBounds(this.get_element());
this._completionListElement.style.width = Math.max(1, elementBounds.width - 2) + 'px';
this._completionListElement.scrollTop = 0;
this.raisePopulated(Sys.EventArgs.Empty);
var eventArgs = new Sys.CancelEventArgs();
this.raiseShowing(eventArgs);
if (!eventArgs.get_cancel()) {
this.showPopup();
// Check if the first Row is to be selected by default and if yes highlight it and updated selectIndex.
if (this._firstRowSelected && (_firstChild != null)) {
this._highlightItem( _firstChild );
this._selectIndex = 0;
}
}
} else {
this._hideCompletionList();
}
},
Monday, June 4, 2007
Database Structure
There will be 6 tables - tables for Redeem gift points needs to be made....
email
pwd
companyname
Address
City
State
Zipcode
ContactPerson1
ContactPerson2
Tel1
Tel2
FaxNo
IsActive
CreatedBy
CreatedOn
ModifiedBy
ModifiedOn
tbl_offer - This table will contain the scheme details
Offerid
Points
Product
Machines
IsActive
CreatedOn
CreatedBy
ModifiedOn
ModifiedBy
tbl_SerialMaster - This table will contain all the Serial numbers of a Product
serialId
SerialNo
MachineName
IsBlock
IsActive
tbl_claim - this table will contain the Claims of a Partner
claimId
ProductName
PartnerId
NoofMachines
T1InvoiceDate
T2InvoiceNo
ClaimDate
IsApproved
tbl_ClaimMachineSerial - This table will will stored the SerialNo;s Against a particulat Claim Registeration along with partner Id
ID
ClaimId
PartnerId
MachineSerial
tbl_Points _ this Table will contain the Points of a particulat Partner
PointId
PartnerId
PointsEarned
PointsRedeemed
- tbl_partner - This table will contain the necessary partner information like
pwd
companyname
Address
City
State
Zipcode
ContactPerson1
ContactPerson2
Tel1
Tel2
FaxNo
IsActive
CreatedBy
CreatedOn
ModifiedBy
ModifiedOn
tbl_offer - This table will contain the scheme details
Offerid
Points
Product
Machines
IsActive
CreatedOn
CreatedBy
ModifiedOn
ModifiedBy
tbl_SerialMaster - This table will contain all the Serial numbers of a Product
serialId
SerialNo
MachineName
IsBlock
IsActive
tbl_claim - this table will contain the Claims of a Partner
claimId
ProductName
PartnerId
NoofMachines
T1InvoiceDate
T2InvoiceNo
ClaimDate
IsApproved
tbl_ClaimMachineSerial - This table will will stored the SerialNo;s Against a particulat Claim Registeration along with partner Id
ID
ClaimId
PartnerId
MachineSerial
tbl_Points _ this Table will contain the Points of a particulat Partner
PointId
PartnerId
PointsEarned
PointsRedeemed
Javascript on Dynamic Textboxes
A=0
B=0
if(this.document.f1.h1.value!="")
{
for(var A=1;A<=this.document.f1.h1.value;A++)
{
if(this.document.getElementById("txt"+A).value=="")
{
alert("Please enter no "+A)
document.getElementById("txt"+A).select();
return false
}
for(var B=A+1;B<=this.document.f1.h1.value;B++)
{
if(this.document.getElementById("txt"+A).value==this.document.getElementById("txt"+B).value)
{
alert("Two no's can't b same "+B)
document.getElementById("txt"+B).select();
return false
}
}
}
}
B=0
if(this.document.f1.h1.value!="")
{
for(var A=1;A<=this.document.f1.h1.value;A++)
{
if(this.document.getElementById("txt"+A).value=="")
{
alert("Please enter no "+A)
document.getElementById("txt"+A).select();
return false
}
for(var B=A+1;B<=this.document.f1.h1.value;B++)
{
if(this.document.getElementById("txt"+A).value==this.document.getElementById("txt"+B).value)
{
alert("Two no's can't b same "+B)
document.getElementById("txt"+B).select();
return false
}
}
}
}
Subscribe to:
Posts (Atom)