Recently I am working on asp.net application but my found that my script is not working and don't know why even I tested in the fiddle.
I want my list box to be filtered when user key in any keyword in the textbox.
My list box ID is "ItemList".
My textbox ID is "txtSearchItem".
here is my script for the page:
<%# Page Title="" Language="C#" MasterPageFile="~/Staff/Staff.Master" AutoEventWireup="true" CodeBehind="AddPackage.aspx.cs" Inherits="ExpressPrintingSystem.Staff.Owner.Package.AddPackage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script type="text/javascript">
$(document.getElementById("<%=txtSearchItem.ClientID%>")).on("keyup", function () {
var search = this.value;
$("option", document.getElementById("<%= ItemList.ClientID %>")).show().filter(function () {
return $(this).text().toLowerCase().indexOf(search.toLowerCase()) < 0;
}).hide();
});
</script>
</asp:Content>
Here is the ListBox with is located in a table:
<td><asp:TextBox ID="txtSearchItem" TextMode="Search" Width="200px" runat="server" ClientIDMode="Static"/><br />
<asp:ListBox ID="ItemList" runat="server" Width="200px" DataSourceID="sdsItem" ClientIDMode="static" DataTextField="ItemName" DataValueField="ItemID"></asp:ListBox>
<asp:SqlDataSource ID="sdsItem" runat="server" ConnectionString="<%$ ConnectionStrings:printDBServer %>" SelectCommand="SELECT [ItemID], [ItemName] FROM [Item] WHERE ([ItemID] LIKE '%' + #keyword + '%') OR ([ItemName] LIKE '%' + #keyword + '%')">
<SelectParameters>
<asp:ControlParameter ControlID="txtSearchItem" DefaultValue="I" Name="keyword" PropertyName="Text" />
</SelectParameters>
</asp:SqlDataSource>
</td>
I not sure where is the error occur. I want the option tag to be hidden when the keywords in the text box is not match with the keywords user type in. The ListBox is linked with a datasource which will call all the record of the item out. Please help me.
Here is my whole complete code:
<%# Page Title="" Language="C#" MasterPageFile="~/Staff/Staff.Master" AutoEventWireup="true" CodeBehind="AddPackage.aspx.cs" Inherits="ExpressPrintingSystem.Staff.Owner.Package.AddPackage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script type="text/javascript">
$(document.getElementById("<%=txtSearchItem.ClientID%>")).on("keyup", function () {
var search = this.value;
$("option", document.getElementById("<%= ItemList.ClientID %>")).show().filter(function () {
return $(this).text().toLowerCase().indexOf(search.toLowerCase()) < 0;
}).hide();
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphStaffContent" runat="server">
<h1>Add Package</h1>
<asp:Label ID="lblError" runat="server" ForeColor="Red" Text=""></asp:Label>
<table>
<tr>
<td><asp:Label ID="lblName" runat="server" Text="Name:"></asp:Label></td>
<td><asp:TextBox ID="txtName" runat="server"></asp:TextBox></td>
<td><asp:RequiredFieldValidator ID="rfvName" runat="server" ControlToValidate="txtName" ForeColor="Red" ErrorMessage="Please fill up the the Name field."></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td><asp:Label ID="lblSupport" runat="server" Text="Support Files:"></asp:Label></td>
<td><asp:CheckBoxList ID="cblSupport" runat="server"></asp:CheckBoxList></td>
</tr>
<tr>
<td><asp:Label ID="lblType" runat="server" Text="Type of Package:"></asp:Label></td>
<td><asp:DropDownList ID="ddlType" runat="server" Height="17px" Width="128px"></asp:DropDownList></td>
</tr>
<tr>
<td><asp:Label ID="lblItems" runat="server" Text="Package's Items:"></asp:Label></td>
<td><asp:Table ID="tblPackageItems" runat="server" Width="100%">
<asp:TableRow>
<asp:TableCell>Item</asp:TableCell>
<asp:TableCell>Quantity</asp:TableCell>
</asp:TableRow>
</asp:Table> </td>
<td><asp:TextBox ID="txtSearchItem" TextMode="Search" Width="200px" runat="server" ClientIDMode="Static"/><br />
<asp:ListBox ID="ItemList" runat="server" Width="200px" DataSourceID="sdsItem" ClientIDMode="static" DataTextField="ItemName" DataValueField="ItemID"></asp:ListBox>
<asp:SqlDataSource ID="sdsItem" runat="server" ConnectionString="<%$ ConnectionStrings:printDBServer %>" SelectCommand="SELECT [ItemID], [ItemName] FROM [Item] WHERE ([ItemID] LIKE '%' + #keyword + '%') OR ([ItemName] LIKE '%' + #keyword + '%')">
<SelectParameters>
<asp:ControlParameter ControlID="txtSearchItem" DefaultValue="I" Name="keyword" PropertyName="Text" />
</SelectParameters>
</asp:SqlDataSource>
</td>
</tr>
<tr>
<td><asp:Label ID="lblEstPrice" runat="server" Text="Estimated Price (RM):"></asp:Label></td>
<td><asp:Label ID="lblEstimatedPrice" runat="server" Text="0"/></td>
</tr>
<tr>
<td><asp:Label ID="lblPrice" runat="server" Text="Package Price (RM):"></asp:Label></td>
<td><asp:TextBox ID="txtPrice" runat="server"></asp:TextBox></td>
</tr>
</table>
<asp:Button ID="btnSubmit" runat="server" Text="Add Package"/>
<asp:Button ID="btnCancel" runat="server" Text="Cancel"/>
</asp:Content>
This is my master page:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="Staff.master.cs" Inherits="ExpressPrintingSystem.Staff.Staff" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Staff Portal</title>
<link rel="stylesheet" href="~/styles/main.css" type="text/css" />
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<div id="page">
<form runat="server">
<div id="header">
<asp:SiteMapDataSource ID="SiteMapDataSourceForStaff" SiteMapProvider="StaffSiteMap" runat="server" ShowStartingNode="false" />
<div>
<img src="<%=Page.ResolveUrl("~/Images/logo/long_logo.png")%>" alt=""/>
<ul id="navigation">
<li class="selected">
Home
</li>
<asp:Repeater runat="server" ID="menu" DataSourceID="SiteMapDataSourceForStaff">
<ItemTemplate>
<li>
<asp:HyperLink runat="server" NavigateUrl='<%# Eval("Url") %>'><%# Eval("Title") %></asp:HyperLink>
<asp:Repeater runat="server" DataSource='<%# ((SiteMapNode) Container.DataItem).ChildNodes %>'>
<HeaderTemplate>
<ul>
</HeaderTemplate>
<ItemTemplate>
<li>
<asp:HyperLink runat="server" NavigateUrl='<%# Eval("Url") %>'><%# Eval("Title") %></asp:HyperLink>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
</li>
</ItemTemplate>
</asp:Repeater>
<li style="float:right;">
<asp:HyperLink ID="userInfoControl" runat="server"/>
<ul id="userMenu" runat="server">
</ul>
</li> </ul>
</div>
</div>
<div id="content">
<div>
<asp:ContentPlaceHolder ID="cphStaffContent" runat="server">
</asp:ContentPlaceHolder>
</div>
</div>
</form>
<footer id="footer">
<div class="footcontent">
<div>
<img src="<%=Page.ResolveUrl("~/Images/logo/long_logo.png")%>" alt=""/>
<ul>
<li>Services</li>
<li>About</li>
<li>Contact</li>
</ul>
</div>
</div>
<div class="footnote">
<div>
<p>© 2017 BY Express Printing System | ALL RIGHTS RESERVED</p>
</div>
</div>
</footer>
</div>
</body>
</html>
This kind of problem is usually encountered when there are conflicts between jQuery and other libraries. To stay out of trouble, call $.noConflict() and don't forget to run your jQuery code after the document is ready
$.noConflict();
jQuery(document).ready(function($){ /**/});
First create a JavaScript file instead of a script tag and than link that file in the master page like this:
<script src="<%=ResolveClientUrl("~/content/assets/vendor/jquery/dist/jquery.min.js")%>">
</script>
Related
I am trying to create a dynamic Multiple-choice Question Quiz, where we have different categories in which there are multiple questions with their individual options. I need to validate that at least one option is selected.
Below is the aspx code which I am using to bind the data:
<asp:ListView ID="lv_cat" runat="server" OnItemDataBound="lv_cat_ItemDataBound">
<EmptyDataTemplate></EmptyDataTemplate>
<ItemTemplate>
<div class="step">
<h4 style="text-align: center;"><%# Eval("Cat_name") %></h4>
<asp:Label ID="lbl_Cat_id" runat="server" Text='<%# Eval("cat_id") %>' hidden="true"></asp:Label>
<asp:ListView ID="Lv_question" runat="server" OnItemDataBound="Lv_question_ItemDataBound">
<EmptyDataTemplate></EmptyDataTemplate>
<ItemTemplate>
<div class="row">
<div class="col-md-10">
<h3><%# Eval("Question") %></h3>
<asp:Label ID="lbl_Q_Id" runat="server" Text='<%# Eval("Q_id") %>' hidden="true"></asp:Label>
<asp:Label ID="lbl_Q_ID_Status" runat="server" Text='<%# Eval("status") %>' hidden="true"></asp:Label>
<%-- <ul class="data-list-2">
<asp:ListView ID="Lv_Answer_check" runat="server" >
<EmptyDataTemplate></EmptyDataTemplate>
<ItemTemplate>
<li>
<input name="rate" type="checkbox" class="required check_radio" id="checkbox" value='<%# Eval("A_id") %>'><label><%# Eval("answers") %></label></li>
</ItemTemplate>
</asp:ListView>
<asp:ListView ID="Lv_Answer_Radio" runat="server" >
<EmptyDataTemplate></EmptyDataTemplate>
<ItemTemplate>
<li>
<input name="rate" type="radio" id="radiobutton" class="required check_radio" value='<%# Eval("A_id") %>'><label> <%# Eval("answers") %></label></li>
</ItemTemplate>
</asp:ListView>
</ul>
</br>--%>
<asp:RadioButtonList ID="Rbl_options" runat="server" Style="text-align: left; margin-left: 30px;" >
</asp:RadioButtonList>
<asp:CheckBoxList ID="CheckBoxList1" runat="server" name="CheckBoxList1" Style="text-align: left; margin-left: 30px;" ></asp:CheckBoxList>
</div>
</div>
</ItemTemplate>
</asp:ListView>
</div>
</ItemTemplate>
</asp:ListView>
and below is the javascript code which I am tried to implement.
<script>
$("input[type='checkbox']").addClass("answer_check");
$(".answer_check").each(function () {
$(this).rules("add", {
required: true,
messages: {
required: "please select atleast one of the below"
}
});
}); </script>
I am trying hard to change the color of a text when it is clicked but not getting success.
There is one label for question, four labels for four options, one label for correct answer and one label for explanation.
What I am trying is when user click on any option then it should match with the correct answer and change the color of the text of that option i.e. when the answer is correct the text color should turn to green otherwise the color should turn to red .
But when I click on any option it is turning to red color only . Correct option should turn to green but it is turning to red . I can't figure out why ?.
Have a look at my code. Show me where I am making mistake and what is the solution.
.aspx :-
<%# Page Title="" Language="C#" MasterPageFile="~/Student/StudentPage.master" AutoEventWireup="true" CodeFile="studpractice.aspx.cs" Inherits="Student_studpractice" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script type="text/javascript">
$(function () {
$(".optionclass").click(function () {
var $thisoption = $(this);
var $corrans = $(".correctans");
if ($thisoption.text() == $corrans.text()) {
$thisoption.css("color", "green");
} else {
$thisoption.css("color", "red");
}
});
});
</script>
<div>
<div id="tabs">
<ul>
<li>Reasoning</li>
<li>Quantitative Aptitude</li>
<li>English</li>
<li>Mathematics</li>
<li>Computer Concepts</li>
</ul>
<div id="tabs-1">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" width="100%">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Panel ID="Panel1" runat="server">
<asp:Label ID="Label1" runat="server" Text='<%#Eval("Question") %>'></asp:Label>
<br />
<br />
<br />
<span>A-</span> <asp:Label class="optionclass" ID="Label2" runat="server" Text='<%#Eval("Option1")%>' ></asp:Label>
<br />
<br />
<span>B-</span> <asp:Label class="optionclass" ID="Label3" runat="server" Text='<%#Eval("Option2")%>'></asp:Label>
<br />
<br />
<span>C-</span> <asp:Label class="optionclass" ID="Label4" runat="server" Text='<%#Eval("Option3")%>'></asp:Label>
<br />
<br />
<span>D-</span> <asp:Label class="optionclass" ID="Label5" runat="server" Text='<%#Eval("Option4")%>'></asp:Label>
<br />
<br />
<asp:Button class="panelButton" runat="server" Text="Show Answer" ClientIDMode="Static" />
<br />
<asp:Panel ID="anspanel" class="AnswerPanel" runat="server" ClientIDMode="Static">
<span>Correct Answer is :-</span><asp:Label class="correctans" ID="Label6" runat="server" Text='<%#Eval("CorrectAns")%>'></asp:Label>
<br />
<br />
<asp:Label ID="Label7" runat="server" Text='<%#Eval("Explanation")%>'></asp:Label>
</asp:Panel>
</asp:Panel>
<br />
<br />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<div id="tabs-2">
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="false" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Panel ID="Panel1" runat="server">
<asp:Label ID="Label1" runat="server" Text='<%#Eval("Question") %>'></asp:Label>
<br />
<br />
<br />
<span>A-</span> <asp:Label class="optionclass" ID="Label2" runat="server" Text='<%#Eval("Option1")%>'></asp:Label>
<br />
<br />
<span>B-</span> <asp:Label class="optionclass" ID="Label3" runat="server" Text='<%#Eval("Option2")%>'></asp:Label>
<br />
<br />
<span>C-</span> <asp:Label class="optionclass" ID="Label4" runat="server" Text='<%#Eval("Option3")%>'></asp:Label>
<br />
<br />
<span>D-</span> <asp:Label class="optionclass" ID="Label5" runat="server" Text='<%#Eval("Option4")%>'></asp:Label>
<br />
<br />
<asp:Button class="panelButton" runat="server" Text="Show Answer" ClientIDMode="Static" />
<br />
<asp:Panel ID="anspanel" class="AnswerPanel" runat="server" ClientIDMode="Static">
<span>Correct Answer is :-</span><asp:Label class="correctans" ID="Label6" runat="server" Text='<%#Eval("CorrectAns")%>'></asp:Label>
<br />
<br />
<asp:Label ID="Label7" runat="server" Text='<%#Eval("Explanation")%>'></asp:Label>
</asp:Panel>
</asp:Panel>
<br />
<br />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<div id="tabs-3">
Tab 3 Content
</div>
<div id="tabs-4">
Tab 4 Content
</div>
<div id="tabs-5">
Tab 5 Content
</div>
</div>
<input type="button" id="btnPrevious" value="Previous" style = "display:none"/>
<input type="button" id="btnNext" value="Next" />
</div>
</asp:Content>
So what wrong you are doing is you are selecting all .correctans and what you should do is select the .correctans specific to that question only.
Change $(".correctans") to $(".correctans")[0] or $(".correctans").first() to get the single correctans element instead of a collection.
EDIT:
Since you have multiple questions and answers on the page, use this to get the correctans for the question they're answering:
var $corrans = $(this).parent().find('.correctans:first');
i have content page in which i am selecting value from drop down on which gridview populate i am here showing my aspx page,
<div>
<table>
<tr>
<td>
<asp:DropDownList ID="ddlConsultant" runat="server"
AutoPostBack="True"
onselectedindexchanged="ddlConsultant_SelectedIndexChanged">
</asp:DropDownList>
</td>
<td>
</td>
<td>
<asp:TextBox ID="txtActivatedOn" runat="server">
</asp:TextBox>
<a href="javascript:show_calendar('<%=txtActivatedOn.ClientID%>','<%=txtActivatedOn.Text%>');">
<img border="0" src="./Images/calendar.gif" alt="calendar" /></a>
</td>
<td>
</td>
<td>
<asp:Button ID="btnUpdateActivated" runat="server" Text="Update Date"
class="button" />
</td>
</tr>
</table>
<div id="grdWithScroll" style="OVERFLOW: auto" onscroll="SetDivPosition()">
<asp:GridView ID="gvProjects" runat="server" AutoGenerateColumns="False" Height="150px"
Width="225px" CellPadding="4" ForeColor="#333333" GridLines="None" OnRowDeleting="gvProjects_RowDeleting"
DataKeyNames="ID" ViewStateMode="Inherit">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="chk_All" runat="server" AutoPostBack="true" OnCheckedChanged="chk_All_CheckedChanged"/>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chk_selector" runat="server" AutoPostBack="true" OnCheckedChanged="chk_selector_CheckedChanged" Checked='<%#bool.Parse(Eval("Proj_Flag").ToString() == "True" ? "True": "False") %>'/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField Visible="false">
<ItemTemplate>
<asp:Label ID="lbl_ID" runat="server" Text='<%# Bind("ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ProjectID" Visible="true">
<ItemTemplate>
<asp:Label ID="lblProjectID" runat="server" Text='<%# Bind("ProjectID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<%--<asp:TemplateField HeaderText="Order #">
<ItemTemplate>
<!-- <asp:Label ID="lblOrderNumber" runat="server" Text=''></asp:Label>-->
</ItemTemplate>
</asp:TemplateField>--%>
<asp:TemplateField HeaderText="Title">
<ItemTemplate>
<a href="javascript:openPopup('DsProjectDetail.aspx?mode=1&cid=<%# Eval("ID") %>&prj=<%#Eval("Title")%>' )">
<%--<%#Eval("Title")%>--%>
<asp:Label ID="lblTitle" runat="server" Text='<%# Bind("Title") %>'></asp:Label></a>
</ItemTemplate>
<ControlStyle Width="400px" />
</asp:TemplateField>
<%-- <asp:TemplateField HeaderText="CompletionDate">
<ItemTemplate>
<asp:Label ID="lblCompletionDate" runat="server" Text='<%# Bind("CompletionDate") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>--%>
<asp:TemplateField HeaderText="ConsultantID" Visible="false">
<ItemTemplate>
<asp:Label ID="lblConsultantID" runat="server" Text='<%# Bind("CompanyID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField DeleteImageUrl="~/Images/Delete.gif" ButtonType="Image" ShowDeleteButton="True" />
</Columns>
</asp:GridView>
</div>
<input type="hidden" id="XPos" runat="server" />
<input type="hidden" id="YPos" runat="server" />
<table>
<tr>
<td>
<asp:Button ID="btnAddProject" runat="server" CssClass="button" Text="New Project"
onclick="btnAddProject_Click" />
</td>
</tr>
</table>
</div>
Javascript i am using are,
<script type="text/javascript">
window.onload = function(){
var strCook = document.cookie;
if(strCook.indexOf("!~")!=0){
var intS = strCook.indexOf("!~");
var intE = strCook.indexOf("~!");
var strPos = strCook.substring(intS+2,intE);
document.getElementById("grdWithScroll").scrollTop = strPos;
}
}
function SetDivPosition(){
var intY = document.getElementById("grdWithScroll").scrollTop;
document.title = intY;
document.cookie = "yPos=!~" + intY + "~!";
}
</script>
<script type="text/javascript">
window.scrollBy(100, 100);
function foo() {
alert("ddd");
if (grdWithScroll != null) alert(grdWithScroll.scrollTop);
}
</script>
and at the end of the page load event i am using,
Page.ClientScript.RegisterStartupScript(GetType(), "MyKey", "SetDivPosition();", true);
i have added this line in
<%# Page Language="C#" MaintainScrollPositionOnPostback="true" ...
and also added in webconfig,
<system.web>
<pages maintainScrollPositionOnPostBack="true" >
</pages>
</system.web>
getting help from this link,
http://stackoverflow.com/questions/12092150/maintain-scroll-bar-position-of-a-div-within-a-gridview-after-a-postback
One think i wanna mention that "onscroll="SetDivPosition()" in div tag showing me warning that on scroll is not valid attribute for div tag
But after doing all this its not working for me firstly i populate gridview with dropdown when grid populate it shows check box column too in all rows that on checked save check box value in database and post back occurs if i am at bottom of grid it scroll to the top after post back
Hopes for your suggestion
Thanks
I have a nested ListView like this :
<asp:ListView runat="server" ID="lvOuter" DataKeyNames="camp_code" OnItemDataBound="lvOuter_ItemDataBound">
<LayoutTemplate>
<ul>
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
</ul>
</LayoutTemplate>
<ItemTemplate>
<li>
<%# Eval("camp_name") %>
<asp:HiddenField ID="hf_camp_code" runat="server" Value='<%# Eval("camp_code") %>' />
<asp:ListView runat="server" ID="lvInner">
<LayoutTemplate>
<ul>
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
</ul>
</LayoutTemplate>
<ItemTemplate>
<li>
<asp:HiddenField ID="hf_main_code" runat="server" Value='<%# Eval("main_code") %>' />
<asp:HiddenField ID="hf_year" runat="server" Value='<%# Eval("year") %>' />
<asp:LinkButton ID="lbtn_dep" runat="server" CommandName="get_dep"><%# Eval("name") %> (<%# Eval("dep_count") %>)</asp:LinkButton>
</li>
</ItemTemplate>
<EmptyDataTemplate>
<ul>
<li>---</li>
</ul>
</EmptyDataTemplate>
</asp:ListView>
</li>
</ItemTemplate>
<EmptyDataTemplate>
---
</EmptyDataTemplate>
</asp:ListView>
What i want to do is :
Collapsing to the outer list view in the beginning and expand under demand .
for example :
- 1-OUTER1
1.1 INNER1
1.2 INNER2
1.3 INNER3
- 2-OUTER2
2.1 INNER1
2.2 INNER2
2.3 INNER3
I want the following in the beginning :
+OUTER1
+OUTER2
How to get this behavior using my nested ListView ?
From FireBug :
<div>
<ul>
<li>
Computer
<input id="ctl00_ContentPlaceHolder1_lvOuter_ctrl0_hf_camp_code" type="hidden" value="1" name="ctl00$ContentPlaceHolder1$lvOuter$ctrl0$hf_camp_code">
<ul>
<li>
<input id="ctl00_ContentPlaceHolder1_lvOuter_ctrl0_lvInner_ctrl0_hf_main_code" type="hidden" value="1" name="ctl00$ContentPlaceHolder1$lvOuter$ctrl0$lvInner$ctrl0$hf_main_code">
<input id="ctl00_ContentPlaceHolder1_lvOuter_ctrl0_lvInner_ctrl0_hf_year" type="hidden" value="2012" name="ctl00$ContentPlaceHolder1$lvOuter$ctrl0$lvInner$ctrl0$hf_year">
<a id="ctl00_ContentPlaceHolder1_lvOuter_ctrl0_lvInner_ctrl0_lbtn_dep" href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$lvOuter$ctrl0$lvInner$ctrl0$lbtn_dep','')">jm</a>
</li>
....
http://jsfiddle.net/EsWv3/1/
$("li.parent").click( function() {
$(this).next(".child").toggle("fast");
});
I think this could work for you
I have this code in my masterpage:
<script type="text/javascript">
function silentErrorHandler() { return true; }
window.onerror = silentErrorHandler;
alert("handled");
</script>
But I am still getting this error:
Error: Unable to get value of the property 'scrollLeft': object is null or undefined
How can I fully suppress these errors without having to set the disable script debugging in ie?
I would fix the error but I have spent too long looking at this issue and no one has commented on my other post:
https://stackoverflow.com/questions/7915208/jscript-runtime-error-on-callback-using-updatepanel
<%# Page Title="" Language="VB" MasterPageFile="~/WinPlan.master" AutoEventWireup="false"
CodeFile="Scheduler.aspx.vb" Inherits="Scheduler" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="act" %>
<%# Register Assembly="DayPilot" Namespace="DayPilot.Web.Ui" TagPrefix="DayPilot" %>
<asp:Content ID="PageHeadContent" ContentPlaceHolderID="page_header_content" runat="Server">
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server" EnableViewState="true">
</asp:ScriptManagerProxy>
<asp:UpdatePanel ID="upnlSearchBar" runat="server">
<ContentTemplate>
<div class="searchBar">
<table id="userSearchBar">
<tr>
<td align="left">
<asp:Label ID="Label1" runat="server" Text="From: " Font-Bold="true" Width="50"></asp:Label>
</td>
<td align="left">
<asp:TextBox ID="txtFromDate" runat="server" Width="80"></asp:TextBox>
<asp:ImageButton ID="imgCalendarFrom" runat="server" Width="18" ImageUrl="~/Images/SmallCalendar.gif" />
<act:CalendarExtender ID="CalendarExtenderFrom" runat="server" Format="dd/MM/yyyy"
Enabled="true" PopupButtonID="imgCalendarFrom" TargetControlID="txtFromDate">
</act:CalendarExtender>
</td>
<td align="left">
<asp:Label ID="l3" Text="" runat="server" Width="20"></asp:Label>
</td>
<td align="left">
<asp:Label ID="Label2" runat="server" Text="To: " Font-Bold="true" Width="30"></asp:Label>
</td>
<td align="left">
<asp:TextBox ID="txtToDate" runat="server" Width="80"></asp:TextBox>
<asp:ImageButton ID="imgCalendarTo" runat="server" Width="18" ImageUrl="~/Images/SmallCalendar.gif" />
<act:CalendarExtender ID="CalendarExtenderTo" runat="server" Format="dd/MM/yyyy"
Enabled="true" PopupButtonID="imgCalendarTo" TargetControlID="txtToDate">
</act:CalendarExtender>
</td>
<td align="left">
<asp:Label ID="l4" Text="" runat="server" Width="20"></asp:Label>
</td>
<td align="left">
<asp:Button ID="btnSearchSchedules" runat="server" Text="Search" Width="60px" BorderStyle="None"
Height="22px" ForeColor="White" CssClass="btn" />
</td>
<td align="left">
<asp:Label ID="L5" Text="" runat="server" Width="20"></asp:Label>
</td>
<td valign="middle">
<asp:Button ID="btnUsers" runat="server" Text="Users" Width="60px" BorderStyle="None"
Height="22px" ForeColor="White" CssClass="btn" OnClientClick="editUsers();" />
</td>
<td align="left" valign="middle">
<asp:Label ID="L6" Text="" runat="server" Width="20"></asp:Label>
</td>
<td valign="bottom">
<asp:CheckBox ID="chkBusinessHours" runat="server" Text=" Show Business Hours Only"
Height="22px" BorderColor="Transparent" Font-Bold="true" ForeColor="Black" AutoPostBack="true" />
</td>
<td width="40px">
</td>
</tr>
</table>
<table id="adminSearchBar" runat="server">
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
<asp:Content ID="MainContent" ContentPlaceHolderID="main_content" runat="Server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
<ContentTemplate>
<div id="dp">
<DayPilot:DayPilotScheduler ID="DayPilotScheduler1" runat="server" CellGroupBy="Day"
DataStartField="StartDate" DataEndField="EndDate" ScrollLabelsVisible="true"
DataTextField="CustomerName" DataValueField="Workcard" DataResourceField="EmployeeCode"
CellDuration="60" CellWidth="50" ViewType="Resources" Width="100%" Heigth="100%"
RowMinHeight="30" RowHeaderWidth="150" HeigthSpec="Max" HeaderFontSize="10pt"
HeaderWidth="150px" HeaderHeight="20" EventFontSize="8pt" EventMoveHandling="CallBack"
TimeFormat="Clock12Hours" DurationBarVisible="false" BusinessBeginsHour="8" BusinessEndsHour="18"
ClientObjectName="dps" EventClickHandling="JavaScript" EventClickJavaScript="editEvent(e.value());"
OnCommand="DayPilotScheduler1_Command" EventCorners="Regular" RowMarginBottom="5"
ContextMenuID="DayPilotContextMenu" TreeIndent="15" TreeImageNoChildren="images/tree_nochildren.png"
TreeImageCollapse="images/tree_collapse.png" TreeImageExpand="images/tree_expand.png"
CssClassPrefix="scheduler_" EventBackColor="" EventFontFamily="" HourNameBackColor=""
HourFontFamily="" HourFontSize="" HeaderFontFamily="" HourBorderColor="" BackColor="#ececfe"
NonBusinessBackColor="White" CellBorderColor="Silver" OnBeforeResHeaderRender="DayPilotScheduler1_BeforeResHeaderRender"
AutoRefreshEnabled="true" AutoRefreshInterval="10" HeightSpec="Max" Height="630">
</DayPilot:DayPilotScheduler>
<DayPilot:DayPilotMenu ID="DayPilotContextMenu" runat="server" CssClassPrefix="menu_">
<DayPilot:MenuItem Action="Javascript" JavaScript="redirect()" Command="Details"
Text="View Job Creator" />
</DayPilot:DayPilotMenu>
<asp:UpdateProgress DynamicLayout="false" DisplayAfter="1" ID="UpdateProgress2" runat="server">
<ProgressTemplate>
<div class="Progress">
<img src="./images/ajax-loader.gif" />
Loading ...
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<act:AlwaysVisibleControlExtender ID="AlwaysVisible" runat="server" TargetControlID="UpdateProgress2"
HorizontalSide="Center" VerticalSide="Middle" HorizontalOffset="0">
</act:AlwaysVisibleControlExtender>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
From the Microsoft documentation:
The onerror event fires for run-time errors, but not for compilation errors. In addition, error dialog boxes raised by script debuggers are not suppressed by returning true. To turn off script debuggers, disable script debugging in Internet Explorer by choosing Internet Options from the Tools menu. Click the Advanced tab and select the appropriate check box(es).
On the bright side, most ordinary IE users (or users of any other browser, for that matter) don't have script debugging enabled.
Seems that the JavaScript code is generated by server side because your ASP.net code doesn't contain any JavaScript code. As a result, it's difficult to tell where goes wrong.