.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

validate both dropdown and listview checkboxes+Javascript

Posted By:      Posted Date: September 12, 2010    Points: 0   Category :ASP.Net
I have checkboxes in one column of  listview and outside the listview I have one  dropdown and one button.when I dont check any checkboxes in listview  fire a validation "Select any one checkbox" on button click.simirarly when I check Checkboxes in listview and I'm leaving to select dropdown fire a validation"Select any item in the dropdownlist" on button click.how to validate both controls(checkboxes in listview and dropdown) when those are not selecting. Many thanks in advance.

View Complete Post

More Related Resource Links

Select all checkboxes in gridview using Javascript


Hello members,


              I have used "Check box" inside the gridview...

              I need,

                           If i select the header check box , It should select all the checkbox inside the gridview...

              I have searched in google for this coding ...I got  lot of codes but couldn't get the correct code...

              I request anyone please provide me the correct code(using Javascript) thanks...

Accessing Label Control In a listview using Javascript



I have a Button and Label nested inside a ListView.

When a User clicks the button i want the Label to display a specific value eg"Pass". Of course being a Listview the Label value will be relevant to the row the button was clicked on.

I want all this to happen on client side, but i am struggling to access the Label via my Javascript??

Any suggestions and examples Would be much appreciated..

validate the selection of atleast one checkbox in the gridview using javascript


 i have a gridview with a checkbox in the templatefield as given  below,

<asp:GridView runat="server" ID="gvAsgnHw"  AutoGenerateColumns="False"   >
        <asp:CheckBox id="cbAsgnHwGrid"   runat="server" /> </ItemTemplate></asp:TemplateField>

         <asp:BoundField DataField="Resource_id" HeaderText="Resource ID"/>
        <asp:BoundField DataField="Resource_name" HeaderText="Hardware Name" />

I want to check the selection of atleast one checkbox on a button click using javascript.
pls help

Javascript code to copy selected dropdown item to clipboard

Does anyone know how I can do this to get the text onto the clipboard?  <input id="Copy" type="button" value="Copy Url" runat="server" onclick="copy();" style="vertical-align: top;" visible="false"/><script type="text/javascript"> function copy() { var sel = document.getElementById("DropDownList1"); var text = sel.options[sel.selectedIndex].value; ??? } </script> </body>  

How to set context key in Cascaded dropdown using javascript

I want to set the context key of a cascaded dropdown during pageload. means if tab index = 0 then contextkey = "1" otherwise 2;  function pageLoad(){ var index = $find("KMTabContainer").get_activeTabIndex(); alert (index); if (index ==0) { alert('Ravi'); var cntxtKey = $find("bScenario"); var ckey ="1" // alert(ckey); alert(cntxtKey.get_contextKey()); cntxtKey.set_contextKey(ckey); alert(cntxtKey.get_contextKey()); } else { var cntxtKey = $find('bScenarioAdd'); cntxtKey.set_contextKey("2"); } }  

checkbox in listview layout template check select all checkboxes in listview itemtemplate

hi,how to do this when the checkbox in listview layout template check select all checkboxes in  listview itemtemplate.I dont give 'Eval 'field to checkbox present in itemtemplate.pls reply me.Many thanks in advance.

Validate (Javascript) if input date is within this range...


I'd like to validate if the inputed date is within this range:

3 weeks before today's date to 3 weeks after today's date 

The following Javascript code checks if the date is within either today's date or 2 weeks before:

var dateSystem = (dateToday.getMonth() + 1) + dtCh + dateToday.getDate() + dtCh + dateToday.getFullYear();
            var prev = new Date();
            //past date 14 dates before today
            prev.setDate(prev.getDate() - 14);
            var pastDate = (prev.getMonth() + 1) + dtCh + (prev.getDate()) + dtCh + prev.getFullYear();
            var time1 = new Date(dateSystem).getTime();
            dtStr = month + dtCh + day + dtCh + year;
            var dateuser = new Date(dtStr);
            var time2 = dateuser.getTime();
            if (time1 - time2 <= 1209600000 && time2 <= time1) {
                return true;
            } else {
                alert("Vaccines/Services date must be within this date range: " + pastDate + " to " + dateSystem);
                return false
            return true


I'm not sure how to modify. I actually got the code above from these forums.

Help is much appreciated!

Validate ASP.net calendar date selected with Javascript?


Is there any way I can use javascript to make sure the user has selected a date from my asp.net calendar? I have the calendar under an update panel:

                        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                                <asp:Calendar ID="Calendar1" runat="server" BackColor="#FFFFCC" BorderColor="Maroon"
                                    BorderWidth="1px" CssClass="calendar" Font-Names="Verdana" Font-Size="9pt" ForeColor="Black"
                                    Height="200px" Width="305px" DayNameFormat="Shortest" ShowGridLines="False">
                                    <SelectedDayStyle BackColor="maroon" BorderColor="Black" BorderWidth="1px" Font-Bold="true" Font-Size="11pt" />
                                    <SelectorStyle BackColor="#FFCC66" />
                                    <TodayDayStyle Font-Bold="true" Font-Size="16pt"/>
                                    <OtherMonthDayStyle ForeColor="#CC9966" />

javascript alert window when dropdown field is selected,



is there a way..where an alert window prompts up to remind the user to select a checkbox when one field in dropdown is selected..for example

there is a dropdown field(Status)  which contains (Tobe confirmed, confirmed and rejected ), when confirmed is chosen..an alert window prompts up reminding the user to select a checkbox(send email) - Yes or No. It is not compulsory for the user to select the checkbox, but if Yes is chosen, the workflow will send an email

DropDown in a ListView


I have a drop down menu inside of a ListView. The DropDown is populated inside the ItemCreated event for the ListView, but I need to set the currently selected value.

<asp:DropDownList ID="ddSIFZoneVersion" runat="server" Width="90px" SelectedItem='<%# Eval("vchZoneVersion") %>'>

<asp:DropDownList ID="ddSIFZoneVersion" runat="server" Width="90px" SelectedItem='<%# Eval("vchZoneVersion") %>'>

I have this in the ASPX, but SelectedItem doesn't work. I've only coded these sorts of things in the codebehind pages, but from what I've read,

I *have* to use the Eval. Unfortunately, I can't find any web pages that have examples of set

Passing multiple arguments from a listview to a JavaScript function


Hello, I have been stuck on how to pass multiple to a JavaScript function in a item template of a list view. Below is my code. Does anyone know the process? Thank you.


                            <td style="width: 114px; height: 139px;">

                                <div style="width: 105px; height: auto">

                                    <img alt="" id="Image7" runat="server" src='<%# DataBinder.Eval(Container.DataItem,"images")%>'

                                        width="100" height="125" border="0" onmouseover='"javascript:show(<%# DataBinder.Eval(Container.DataItem,"images")%>)","(<%# DataBinder.Eval(Container.DataItem,"filename")%>)","(<%# DataBinder.Eval(Container.DataItem,"caption")%>)",1,234'

asp dropdown - onchange="javascript: select_country(this.options[this.selectedIndex].text);"


With a regular form drop-down box I can use the onchange event to fire off some javascript with out a page refresh or postback to the server. The above code is not working with an asp drop-down control. Is there a way to make this work? 

I have form that hides and shows different textboxes depending on selected values in a dorp-down but it does cause a postback which refreses the screen I want to do this wiithout refreshing the screen and figured Javascript and hide and show divs etc would work.

<script type="text/javascript" language="javascript">
function select_country(selectedcountry)
var country = selectedcountry;

if(country == "United States")
//do nothing;
// hide state drop-down and the state label.
// code goes here...............
} } </script>

The drop-down:

<asp:DropDownList ID

Javascript code to search item in dropdown.



I want to know how to select dropdown item using javascript when user type in dropdown? 

The dropdown may be binded with a datasource or have same value list.

I have asp.net2.0 framework.

Please don't advise for using ajax.

My question is to know the way of doing this task only using JAVASCRIPT.


Please reply as soon as possible.

what is the syntax for populating dropdown in Javascript using web service?



I have written the web method in web service like this


    public List<Location> FindAllCountries()
        List<Location> locations = new List<Location>();
        string connectionString =
            "Data Source=.;Initial Catalog=Test;Integrated Security=True";
        using (SqlConnection connection = new SqlConnection(connectionString))
            using (SqlCommand command = new SqlCommand())
                command.Connection = connection;
                command.CommandText = "SelectAllCountries";
                command.CommandType = CommandType.StoredProcedure;
                using (SqlDataReader dataReader = command.ExecuteReader())
                    Location location;
                    if (dataReader != null)
                        while (dataReader.Read())
                            location = new Location();
                            location.CountryID = (int)dataReader["CountryID"];
                            location.CountryName = Convert.ToString(dataReader["CountryName"]);
        return locations;

I m calling the webservic

how to get dropdown list data VALUE FIELD property in JavaScript



im getting  'ON' as value instead of its actual value

Saving checkboxes in ListView


Hey guys,

I have a view that contians a list of object 'Students'. The object Student has a boolean which I show on the list page as a boolean. 


    <% foreach (var item in Model) { %>

            <td><%=Html.CheckBox("Absence", item.getAbsence())%></td>

So, as you can see, upon generating that page, the checkboxes will automatically get checked/unchecked. 

I am now looking for a way on how to quickly save that list of Students (if possible, where only the checkbox got changed) in a table in my database. I'm using EF/ADO.Net

ASP.NET, HTML, JavaScript Snippet Support (VS 2010 and .NET 4.0 Series)

This post covers another useful improvement in VS 2010 - HTML/ASP.NET/JavaScript snippet support. Snippets allow you to be more productive within source view by allowing you to create chunks of code and markup that you can quickly apply and use in your application with a minimum of character typing.

Visual Studio has supported the concept of "snippets" for VB and C# in previous releases - but not for HTML, ASP.NET markup and JavaScript. With VS 2010 we now support snippets for these content types as well.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend