Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts

Thursday, June 13, 2013

How hash-based/pushState navigation works

 
For hash-based navigation, the visitor's position in a virtual navigation space is stored in the URL hash, which is the part of the URL after a 'hash' symbol (e.g.,/my/app/#category=shoes&page=4). Whenever the URL hash changes, the browser doesn't issue an HTTP request to fetch a new page; instead it merely adds the new URL to its back/forward history list and exposes the updated URL hash to scripts running in the page. The script notices the new URL hash and dynamically updates the UI to display the corresponding item (e.g., page 4 of the "shoes" category).

This makes it possible to support back/forward button navigation in a single page application (e.g., pressing 'back' moves to the previous URL hash), and effectively makes virtual locations bookmarkable and shareable.

PushState is an HTML5 API that offers a different way to change the current URL, and thereby insert new back/forward history entries, without triggering a page load. This differs from hash-based navigation in that you're not limited to updating the hash fragment — you can update the entire URL.

Tuesday, April 30, 2013

Sort Items in Dropdown List Using Jquery





HTML:

<form id="form1" runat="server">
<div class="smallDiv">
<h2>Click on the Sort Button to Sort the DropDownList </h2>
<asp:DropDownList ID="DDL" runat="server" >
<asp:ListItem Text="Item3" Value="3"></asp:ListItem>
<asp:ListItem Text="Item1" Value="1"></asp:ListItem>
<asp:ListItem Text="Item4" Value="4"></asp:ListItem>
<asp:ListItem Text="Item5" Value="5"></asp:ListItem>
<asp:ListItem Text="Item2" Value="2"></asp:ListItem>
</asp:DropDownList>
<br /><br />
<asp:Button ID="btnSort" runat="server" Text="Sort" />
<p id="para"></p>
<br /><br />
Tip: Items are sorted in an Ascending order
</div>
</form>

Jquery:
<script type="text/javascript">
$(function() {
$('input[id$=btnSort]').click(function(e) {
e.preventDefault();
var sortedDdl = $.makeArray($('select[id$=DDL] option'))
.sort(function(o, n) {
return $(o).text() < $(n).text() ? -1 : 1;
});
$("select[id$=DDL]").html(sortedDdl).val("1");
$("#para").html("Items were Sorted!");
$(this).attr("disabled", "disabled");
});
});
</script>

Explanation:

In the code shown above, when the user clicks on the Sort button, the <option> elements are converted to an array using $.makeArray().

$.makeArray($('select[id$=DDL] option'))

The JavaScript built-in sort() function is used on this array, which does an in-place sort of the array.

$.makeArray($('select[id$=DDL] option'))
.sort(function(o, n) {
return $(o).text() < $(n).text() ? -1 : 1;
});

The final step is to empty the contents of the DropDownList and then use the .html() to replace the existing <options> with the sorted <options>.

$("select[id$=DDL]").empty().html(sorted)

The val("1") sets the first option as selected, after the sorting has been done.

Saturday, April 20, 2013

Show and Hide ASP.NET Panels with Animation using jQuery



HTML:

<form id="form1" runat="server">
<div class="smallDiv">
<h2>Click on a Radio Button to Display/Hide the
Contents of a Panel</h2>
<asp:RadioButtonList ID="rbl" runat="server" class="tbl">
<asp:ListItem Text="Toggle" Value="0"></asp:ListItem>
<asp:ListItem Text="SlideUpDown" Value="1"></asp:ListItem>
<asp:ListItem Text="SlideToggle" Value="2"></asp:ListItem>
<asp:ListItem Text="Animate" Value="3"></asp:ListItem>
</asp:RadioButtonList>
<br />
Tip: Each RadioButton produces a different animation
</div>
<br /><br />
<div class="bigDiv">
<asp:Panel ID="panelText" runat="server" CssClass="panel">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc urpis nunc, placerat ac, bibendum non,  ellentesque nec, odio. Nulla fringilla aliquet nibh. Donec placerat, massa id commodo ornare, justo lectus faucibus leo, in aliquam nisl quam varius
</asp:Panel>
</div>
</form>

Jquery Script:

<script type="text/javascript">
$(function() {
var $radBtn = $("table.tbl input:radio");
var $panel = $('div.panel');
$radBtn.click(function() {
var value = $(':radio:checked').val();
switch (value) {
case '0':
$panel.toggle('slow');
break;
case '1':
if ($panel.is(":hidden")) {
$panel.slideDown("fast");
} else {
$panel.slideUp("fast");
}
break;
case '2':
$panel.slideToggle('slow');
break;
case '3':
$panel.animate({
height: 'toggle',
margin: 'toggle',
opacity: 'toggle'
}, 500);
break;
default: ;
}
});
});
</script>

Explanation:

In this sample, I will demonstrate to you 4 different ways of displaying and hiding the content of a Panel. The selectors are cached into variables as shown below:

var $radBtn = $("table.tbl input:radio");
var $panel = $('div.panel');

In the first method, we use toggle() which toggles the visibility of all matched elements without an animation.

$panel.toggle('slow');

The second method uses slideUp() to hide, and slideDown() to display the matched elements in a sliding motion.

if ($panel.is(":hidden")) {
$panel.slideDown("fast");
} else {
$panel.slideUp("fast");
}

The third method simplifies the technique adopted in the second method by using slideToggle(), which toggles the visibility of all matched elements using a sliding motion. Since we are using the same radio button to trigger the event, slideToggle() is more relevant here, rather than using slideUp or slideDown().

$panel.slideToggle('slow');

And finally the fourth method that shows how to make custom animations by using animate(). In this example, we are animating some style properties (height, margin and opacity) of the Panel.

$panel.animate({
height: 'toggle',
margin: 'toggle',
opacity: 'toggle'
}, 500);

Wednesday, April 17, 2013

Fit Iframe to Screen Size

 
My HTML page body looks like below.

<body>
<div id="wrapper">
<div id="top-contact"><img src="http://mysite.com.au/images/logo.png" width="232" height="59" alt="Contac No" /></div>
<div id="top-menu"> &nbsp; <a href="landing.aspx">Landing </a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<a href="OnTimeLearning.aspx">Learn OnTime</a>&nbsp;&nbsp;&nbsp;|
</div>
<iframe src="https://mysite.ontimenow.com" width="100%" class="myIframe"></iframe>
<div id="fotter-ontime">© 2013 RED ROCK Software Solutions</div>
</div>
</body>



I have two div tags for the header and the footer in between i have the iframe. Now we need to set the iframe size to fit any screen size.

Using Jquery i'm going to reduce the heights of the two div tags on the header and footer and the width ratio is set to 100%.

<script type="text/javascript" src="Scripts/jquery-1.8.3.js"></script>
<script language="javascript">
$(document).ready(function () {
var height = $(window).outerHeight() - ($("#top-menu").outerHeight() + $("#fotter-ontime").outerHeight());
$('.myIframe').css('height', height + 'px');
})
</script>

Tuesday, April 9, 2013

What is web storage in HTML5?

 
The term web storage refers to HTML5’s client-side data-storage mechanism. Web storage allows you to store data on the client side as key-value pairs. The W3C recommended a web storage size limit of 5MB per origin (see the section “Security Considerations for Web Storage” to learn more about origins). However, individual browsers may slightly deviate from this limit. For example, IE8 allows web storage of up to 10MB.

Although both web storage and cookies store data on the client side, they work differently. Cookies are passed between client and server with each and every request from a given web site. On the other hand,
web storage is never passed to the server automatically. If you need to transmit data from web storage to
the server-side code, you must resort to a programmatic approach such as jQuery calling server-side code
or a hidden form field. Additionally, unlike cookies, you can’t set an expiration time for web storage. You
either need to write code to delete stale items or count on the user to delete the stale items using an option
in the browser.

Web storage comes in two flavors: session storage and local storage. These two types are exposed as sessionStorage and localStorage attributes of the window object, respectively. As you might have guessed,
session storage is persisted as long as the current browser (or its tab) instance is running. The moment you
close the browser instance (or tab), the data is removed. If you load the web site again later, it can’t accessany of the previously stored data. Session storage is suitable for a single transaction. Local storage, unlike session storage, stores data across multiple instances of the browser and also beyond the current session. In summary, web storage is good choice if

• You need to store data exceeding the size limits of cookie-based storage.
• You don’t need to pass data to and from the server with every request.
• You don’t need to set any specific expiration time for the data.

However, web storage may not be a good choice if

• You wish to store a huge amount of data.
• Your data can’t be easily stored as key-value pairs (binary data or BLOBS, for example).
• Data to be stored is sensitive.

Sunday, April 7, 2013

Enabling Spell-Check in HTML Form

 

In HTML5 we can use spellcheck attribute in textarea HTML element to enable the spell check ability. By setting it to true it'll enable the spell check ability and setting it to false will disable the spell check ability.

<textarea id="textarea1" rows="5" cols="50" spellcheck="true"></textarea>




Friday, April 5, 2013

Date Time Picker in HTML5

 
In ASP.NET Web Forms, the Calendar server control lets you pick dates. However, the biggest downside of Calendar is that it requires a post back when a date is selected. No wonder ASP.NET developers often used JavaScript-based pop-up date-time pickers in their web applications. It would be better if the browser itself could display a datetime picker, and that’s where the date and time input types come into the picture. Using these input types, you can select a date, a time, or both. The user can also select a complete week or month rather than a specific day or time.

■ Note As of this writing, Opera is the only browser that displays a pop-up date-time picker for the date and time input types. Chrome displays a pop-up date picker only when the input type is date; it renders a plain text box for other date and time types. Also, there is a difference in the display format for date. Opera, for example, displays dates in yyyy-MM-dd format, whereas Chrome displays them as per machine date format.
<input id="dt1" type="date" />
<input id="dt2" type="time" />
<input id="dt3" type="datetime" />
<input id="dt4" type="datetime-local" />
<input id="dt5" type="week" />
<input id="dt6" type="month" />

The six date-time input types allow you to accept date, time, date and time, local date and time, week, and month, respectively. The dates are displayed in yyyy-MM-dd format, whereas times are displayed in hh:mm:ss format. For weeks and months, the format is yyyy-Www and yyyy-MM, respectively. Below image shows how Opera displays these date-time input types.





Range Selector in HTML5

 


At times, you need to select (rather than enter) values falling within a specific range. Recollect the custom video player you developed in Chapter 3: you provided the facility to change the player’s volume. In such
cases it isn’t appropriate to expect the user to enter a volume level. Instead, it’s better to let them select a
volume level from a range. The following markup shows how you can use the range input type:

<input id="range1" type="range" min="1" max="5" step="1" />

Attributes such as min, max, and step have the same significance as for the number input type (min and max control the control’s minimum and maximum allowed values, and step controls the jump in the value).

Thursday, April 4, 2013

E-mail Validation in HTML5



E-mail addresses are commonly used on web sites for variety of reasons ranging from user registrations to
contact forms. You can accept e-mail addresses using the email input type.

<span>Enter your email address :</span>
<br />
<input id="email" type="email" />
<br />
<input type="submit" value="Submit"/>


As you can see, the type attribute is set to email. If you try to enter an invalid e-mail address, the browser displays an error message.

Notice that the error message is displayed only if the text box contains a value. If the text box is left empty, no validation is performed. This behavior is similar to ASP.NET validation controls.

Tuesday, April 2, 2013

Refresh div tag content

Below ASP.NET web form uses jquery to change the content inside a div tag.


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    $("#changePanel").click(function() {
    var data = "foobar";
    $("#panel").hide().html(data).fadeIn('fast');
    })
  });
    </script>
    <style type="text/css">
    div {
    padding: 1em;
    background-color: #00c000;
     }

    input {
    padding: .25em 1em;
     }​
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div id="panel">my data</div>
    <input id="changePanel" value="Change Panel" type="button"/>​
 
    </form>
</body>
</html>

Monday, April 1, 2013

Open .pdf inside a DIV tag

 
You can use HTML5 object element for opening a pdf document inside a div element. Below is a sample code.

<div id="target">
<object data="PDF/File_16.pdf" type="application/pdf" width="100%" height="700">
alt : <a href="PDF/File_16.pdf">test.pdf</a>
</object>
</div>

Friday, March 29, 2013

Embedding Silverlight Video Files in HTML5

Microsoft’s solution to displaying media files in a web page is Silverlight. Silverlight is seen as a competitor to Flash, but because it’s a relatively recent invention, it lags behind Flash in terms of popularity and widespread use. However, Silverlight is a flexible and powerful platform that can be programmed using .NET tools such as Visual Studio and Visual C#. You can also encode existing media files into a Silverlight specific format using Expression Web.

<object data="data:application/x-silverlight-2"
type="application/x-silverlight-2" width="300" height="300">
<param name="source" value="silverlightvideos/CleanTemplate.xap"/>
<param name="background" value="white" />
<param name="minRuntimeVersion" value="4.0.50401.0" />
<param name="autoUpgrade" value="true" />
<param name="enableHtmlAccess" value="true" />
<param name="enableGPUAcceleration" value="true" />
<param name="initparams" value='playerSettings =<Playlist>
<DisplayTimeCode>false</DisplayTimeCode>
<EnableCachedComposition>true</EnableCachedComposition>
<EnableCaptions>true</EnableCaptions>
<EnableOffline>true</EnableOffline>
<EnablePopOut>true</EnablePopOut>
<StartMuted>false</StartMuted>
<StartWithPlaylistShowing>false</StartWithPlaylistShowing>
<StretchNonSquarePixels>NoStretch</StretchNonSquarePixels>
<Items>
<PlaylistItem>
<AudioCodec>WmaProfessional</AudioCodec>
<Description></Description>
<FileSize>1349539</FileSize>
<FrameRate>25</FrameRate>
<Height>360</Height>
<IsAdaptiveStreaming>false</IsAdaptiveStreaming>
<MediaSource>silverlightvideos/Video2.wmv</MediaSource>
<ThumbSource></ThumbSource>
<VideoCodec>VC1</VideoCodec>
<Width>640</Width>
</PlaylistItem>
</Items>
</Playlist>'/>
<a href="http://go2.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;">
<img src="http://go2.microsoft.com/fwlink/?LinkId=108181"
alt="Get Microsoft Silverlight" style="border-style: none;"/>
</a>
</object>

Notice how the <object> tag now includes many pieces of information. The <param> and <Playlist> elements supply a great deal of data such as the path of the Silverlight compressed output file (.xap) and the configuration of the video being played.

Embedding Audio Files in HTML5

 
To embed an audio file into a web page, you can use an <object> tag.

<body>
<h2>Play Audio File</h2>
<object data="Media/Song.mp3" />
</body>


The data attribute of the <object> tag points to an MP3 audio file residing in the Media folder.

Embedding Flash Video Files in HTML5

 
Adobe Flash is one of the most popular ways of embedding video files in web pages. Due to its popularity,
all the leading browsers support the Flash plug-in. You can use the <object> tag to embed Flash videos in a
web page.

<object id="flash1" data="Media/Video1.swf" type="application/x-shockwave-flash" height="200" width="200"> 
<param name="movie" value="Media/Video1.swf"> 
</object> 

 The <object> tag this time plays a Flash video file Video1.swf. The type attribute specifies the MIME type for Flash videos (application/x-shockwave-flash).

Tuesday, March 26, 2013

Display CheckBox Checked Items using Jquery



HTML:

<form id="form1" runat="server">
<div class="smallDiv">
<h2>Dynamically display the checked options</h2>
<br />
<asp:CheckBox ID="cb1" runat="server" Text="Option One" /><br />
<asp:CheckBox ID="cb2" runat="server" Text="Option Two" /><br />
<asp:CheckBox ID="cb3" runat="server" Text="Option Three" /><br />
<br />
Tip: Choosing the CheckBoxes displays the CheckBox text below
<br /><br />
<p id="para"></p>
</div>
</form>

Jquery Script:

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$(function () {
var arr;
$('input:checkbox').click(function (e) {
trackChecked();
});

function trackChecked() {
var checked = $(':checkbox:checked');
arr = [];
checked.each(function () {
arr.push($(this).next().text());
});
$("#para").html(arr.join('</br>'));
}
});
</script>

Enable/Disable ASP.NET button on CheckBox Checked/Uncheked using Jquery



HTML:

<form id="form1" runat="server">
<div class="smallDiv">
<h2>Click on the Checkbox to Enable the Button control</h2>
<asp:CheckBox ID="cb1" runat="server"
Text="Check To Toggle the Enabled status of the Button"
Tooltip="Click Here To Enable/Disabled the CheckBox"/><br /><br />
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
</div>
</form>

Jquery Script:

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$(function () {
var $btn = $(":submit[id$=btnSubmit]");
var $chk = $(":input:CheckBox[id$=cb1]");

// check on page load
checkChecked($chk);

$chk.click(function () {
checkChecked($chk);
});

function checkChecked(chkBox) {
if ($chk.is(':checked')) {
$btn.removeAttr('disabled');
}
else {
$btn.attr('disabled', 'disabled')
}
}
});
</script>

Make the CheckBox a Required Field using jQuery



HTML:

<div class="smallDiv">
<h2>Check Atleast One CheckBox before submitting the Form</h2>
<asp:CheckBox ID="cb1" runat="server" Text="Option One" /><br />
<asp:CheckBox ID="cb2" runat="server" Text="Option Two" /><br />
<asp:CheckBox ID="cb3" runat="server" Text="Option Three" />
<br /><br />
<asp:Button ID="btnSubmit" runat="server" Text="Submit"
ToolTip="Select atleast one checkbox before clicking" />
<br /><br />
Tip: If the user has checked atleast one checkbox, and clicks the
Submit button, a postback occurs, otherwise the user is prevented
from submitting the form.
</div>

Jquery Script:

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$(function () {
$('input[id$=btnSubmit]').click(function () {
var checked = $(':CheckBox:checked').length;
if (checked == 0) {
alert('Atleast one checkbox should be selected!');
e.preventDefault();
}
else {
alert('postback occured!');
}
});
});
</script>

Monday, March 25, 2013

Synchronize Scrolling of Two Multiline TextBoxes using jQuery



HTML:

<div class="bigDiv">
<h2>Click and scroll in the left textbox to see the synchronized scroll in right textbox</h2><br /><br />
<asp:TextBox ID="tb1" runat="server" TextMode="MultiLine"
Text="Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum
Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum"
Tooltip="Click on scrollbar to see the scroll on right box" Rows="5"/>

<asp:TextBox ID="tb2" runat="server" TextMode="MultiLine" Text="Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum"
Rows="5"/>
<br /><br />
Tip: Scrolling the right textbox does not affect the left one.
</div>

Jquery Script:

<script type="text/javascript">
$(function() {
var $tb1 = $('textarea[id$=tb1]');
var $tb2 = $('textarea[id$=tb2]');
$tb1.scroll(function() {
$tb2.scrollTop($tb1.scrollTop());
});
});
</script>

Sunday, March 24, 2013

Using the jQuery $.ajax() Method in a Web Forms Application

The WCF service that converts temperature values between Celsius and Fahrenheit is shown below.

namespace AjaxWebForm
{
[DataContract]
public class TemperatureData
{

[DataMember]
public decimal Value { get; set; }
[DataMember]
public string Unit { get; set; }

}

[ServiceContract]

public interface IService
{
[OperationContract]

[WebInvoke(Method = "POST",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json)]
TemperatureData Convert(TemperatureData t);
}

public class Service : IService
{
public TemperatureData Convert(TemperatureData t)
{
if (t.Unit == "C")
{
t.Value = (t.Value * 1.8m) + 32;
t.Unit = "F";
}

else
{
t.Value = (t.Value - 32) / 1.8m;
t.Unit = "C";
}

return t;
}
}
}

The TemperatureData class represents the data contract of the WCF service and contains two data member properties: Value and Unit. The IService interface represents a service contract for the service and defines a single method Convert(). The Convert() method accepts a TemperatureData object and returns a TemperatureData object after converting the temperature value to the other scale.

Notice that Convert() is decorated with an [WebInvoke] attribute. Due to this attribute, Convert() becomes callable from the client-side jQuery code. The RequestFormat and ResponseFormat properties of the [WebInvoke] attribute specify JSON as the communication format during request and response, espectively. The Method property specifies that Convert() can be invoked by HTTP POST requests. The Service class implements Convert(). The Convert() method checks the Unit of the incoming TemperatureData object and, depending on the Unit, converts the Value to the other scale.

The Service class’s Convert() method can be called using jQuery’s $.ajax() function as shown below
Using $.ajax() to Call the WCF Service Convert() Method

$(document).ready(function () {
$("#Button1").click(function () {
url = "Service.svc/Convert";
data = '{"Value":"' + $("#Text1").val() + '","Unit":"' + $("#Select1").val() + '"}';
$.ajax({
type: "POST",
url: url,
data: data,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
error: OnError
})
});
});

The Convert button’s click event handler contains the jQuery code for invoking the Convert() method. The $.ajax() function has many configurable settings. The url setting allows you to specify the remote resource URL. For a WCF service, the URL takes the form <path_to_svc_file>/<method_name>.

The type option lets you specify the HTTP request type to be used while making the request. The Convert() method is configured with the [WebInvoke] attribute to use a POST method, and hence type is POST. The data setting indicates the data to be sent to the server (if any) while making the call. Notice how data is captured in JSON format. A JSON object takes the form of key-value pairs: a key and its value are separated by a colon (:), and multiple key-value pairs are delimited by a comma (,).

The dataType setting governs the data type of the response (XML, JSON, and so on). Recollect that the [WebMethod] attribute specified ResponseFormat as JSON, so dataType here must be set to JSON to correctly process the data coming from the server.

If Convert() returns successfully, the function specified by the success option (OnSuccess) is called. If there is any error while calling the WCF service, a function specified by the error option (OnError) is called. The OnSuccess() function is where you process the data returned from the WCF service. OnSuccess() receives the return value of Convert() (the TemperatureData object) as a parameter. You can access its Value and Unit properties and display an alert box to the user.

In the OnError() function, you typically flag the error to the user or take some corrective action. OnError() receives an error object; you can display its status and statusText properties to the user. Figure shows a sample run of the Web Forms application.



Saturday, March 23, 2013

Remove DropDownList value on select change

Consider the below dropdown list.

<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>Select Below</asp:ListItem>
<asp:ListItem>aaaa</asp:ListItem>
<asp:ListItem>bbb</asp:ListItem>
<asp:ListItem>ccc</asp:ListItem>
<asp:ListItem>ddd</asp:ListItem>
</asp:DropDownList>

Lets say we need to remove the item at 0th index when user selects an item from the list.

Jquery Script:
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript"> 
 $(document).ready(function () { 

 $("#<#= DropDownList1.ClientID #>").change(function () {

 $("#<#= DropDownList1.ClientID #> option[value='0']").remove();
 }); 

 }); 

</script>