Monday, November 16, 2009

sys is undefined

The reason for this error is your web.config does not contain all the settings required for an ajax enabled web site.
First , generate an ajax enabled web site namely ajaxsite1 and compare your web.config with that of ajaxsite1.
you observe that code in httpHandlers  is not there in your website or it might be improper.
Replace the web.config code in ajaxsite1 in to your website.
See that after running you will ge 'Done' at the bottom left.Previously you get 'Done with Errors' message in this portion.
Note:
All this errors and exceptions generally occur if you are working with Ajax Controls.You will  not get your ajax controls functionality in your  webpage unless you clear all these script errors.
Some of the controls that may raise this error are AutoComplete,CalendarExtendar etc

Tuesday, November 10, 2009

Reset DropDownList to Default Value

Use following lines:

DropDownList1.SelectedIndex = 0;

or

DropDownList1.ClearSelection();
DropDownList1.Items.FindByText("--Select--").Selected = true;

or

DropDownList1.ClearSelection();
DropDownList1.Items.FindByValue("--Select--").Selected = true;


Note:

We need to mention DropDownList1.ClearSelection(); before using DropDownList1.Items.FindByValue("--Select--").Selected = true
(or)DropDownList1.Items.FindByText("--Select--").Selected = true

Otherwise you will get an error 'Cannot have multiple items selected in a DropDownList'

Wednesday, November 4, 2009

How to access asp.net server controls usingJavaScript?

<form id="form1" runat="server">
<div>


<asp:textbox id="TextBox1" runat="server">
  1. document.getElementById('<%=TextBox1.ClientID%>').value;
    ClientID - server control identifier generated by ASP.NET

  2. document.forms[0]['TextBox1'].value;