Uncaught TypeError: Cannot set properties of null (setting 'Handle') - ajaxcontroltoolkit

i got the following error msg in [Console] if i put [MultiHandleSliderExtender] into ChildPage. But it's working fine if put into normal aspx page. Plesae help me. tq
enter image description here
Not Working
MastePage.master
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:ContentPlaceHolder id="body" runat="server">
</asp:ContentPlaceHolder>
</form>
</body>
</html>
Notworking.aspx (ChildPage)
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="body" Runat="Server">
<div style="padding: 100px;">
<cc1:MultiHandleSliderExtender ID="mhse_year_range" runat="server" TargetControlID="txt_year_range"
BehaviorID="multiHandleSliderTwo" Minimum="2000" Maximum="2022" Steps="22" Length="400">
<MultiHandleSliderTargets>
<cc1:MultiHandleSliderTarget ControlID="txt_year_from" />
<cc1:MultiHandleSliderTarget ControlID="txt_year_to"/>
</MultiHandleSliderTargets>
</cc1:MultiHandleSliderExtender>
<br /><br />
<asp:TextBox ID="txt_year_from" runat="server" Text="2000"></asp:TextBox>
<asp:TextBox ID="txt_year_to" runat="server" Text="2022"></asp:TextBox>
<asp:TextBox ID="txt_year_range" runat="server"></asp:TextBox>
</div>
</asp:Content>

Related

ajaxctroltoolkik.ModalPopupextender. Stops working after 10 calls to Show()

I have problems with the ModalPopupExtender.
I set the targetcontrolid to a hidden field and calls the show method from code behind. Every thing works fine until the 10th time i call the show method. Then it suddenly stops working. The "dialog" is no where to be seen. The controls on the page no longer gets disabled. The code behind get called when i click the button that is calling the show method but calls to the show method has no effect.
I use Visual Studio 2010
Here is my aspx page:
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="MessageBoxTest.aspx.cs" Inherits="SeceOfC2.TEST.MessageBoxTest" %>
<%# Register tagName="MessageBox" tagPrefix="uc" src="~/Dialogs/MessageBox.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:UpdatePanel runat="server">
<ContentTemplate>
<asp:Button runat="server" ID="TestButton" Text="Test" OnClick="TestButton_OnClick" />
<asp:HiddenField runat="server" ID="_Hint"/> <%--Brukt til å vite hvorfor denne dialogen ble kalt.--%>
<asp:HiddenField runat="server" ID="_Parameters"/> <%--Her lagres parameterdata som en Json string.--%>
<asp:Button runat="server" ID="_dummy"/>
<asp:Panel runat="server" ID="MessageBoxPanel">
<asp:Panel runat="server" ID="MessageBoxBorderPanel" BorderColor="LightGray">
<div class="dialogheader">
<div style="text-align: center; float: left">
<asp:Label runat="server" ID="lbHeader"></asp:Label>
</div>
<div style="float:right">
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Images/Icons/Small/navigate_cross.png" />
</div>
<div style="clear:both"></div>
</div>
<div class="dialogbody" style="min-height: 50px">
<asp:Label runat="server" ID="lbBody"></asp:Label>
</div>
<div class="dialogbody" style="text-align: center">
<asp:Button runat="server" ID="OKButton" Text="OK" OnClick="OnOkClicked"/>
</div>
</asp:Panel>
</asp:Panel>
<ajaxToolkit:ModalPopupExtender runat="server" ID="MessageBoxPopupExtender" TargetControlID="_dummy" PopupControlID="MessageBoxPanel" RepositionMode="RepositionOnWindowResizeAndScroll" PopupDragHandleControlID="MessageBoxBorderPanel" DropShadow="True" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
The masterpage containing the script manager:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="SeceOfC2.SiteMaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
<title></title>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
</asp:ContentPlaceHolder>
<script language="JavaScript1.2" src="/scripts/jquery-1.4.1.js" type="text/javascript" defer="defer"></script>
<script type="text/javascript">
window.onresize = function(event) {
var height = $(window).height();
var width = $(window).width();
$.ajax({
url: "/HttpHandlers/getwindowsize.ashx",
type: "POST",
data: {
Height: height,
Width: width,
selectedValue: selectedValue
},
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(response) {
// do stuff
}
});
}
</script>
</head>
<body>
<form runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div class="page">
<div class="header">
<div class="title">
<h1>
SenseOfC Drill execution prototype
</h1>
</div>
<div class="loginDisplay">
<asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
<AnonymousTemplate>
[ Log In ]
</AnonymousTemplate>
<LoggedInTemplate>
Welcome <span class="bold"><asp:LoginName ID="HeadLoginName" runat="server" /></span>!
[ <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" LogoutPageUrl="~/"/> ]
</LoggedInTemplate>
</asp:LoginView>
</div>
<div class="clear hideSkiplink">
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
<Items>
<asp:MenuItem NavigateUrl="~/Content/Users/DrillView.aspx" Text="Home"/>
<asp:MenuItem NavigateUrl="~/Content/Administrators/TreatmentView.aspx"
Text="Admin" Value="Admin"></asp:MenuItem>
<asp:MenuItem NavigateUrl="~/About.aspx" Text="About"/>
</Items>
</asp:Menu>
</div>
</div>
<div class="main">
<asp:ContentPlaceHolder ID="MainContent" runat="server"/>
</div>
<div class="clear">
</div>
</div>
<div class="footer">
</div>
</form>
</body>
</html>
and here is my code behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SeceOfC2.Dialogs;
using SeceOfC2.Tools;
namespace SeceOfC2.TEST
{
public partial class MessageBoxTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void TestButton_OnClick(object sender, EventArgs e)
{
Show("TEST", "TEST");
}
public void Show(string caption, string message, string hint = "", MessageBox.Buttons buttons = MessageBox.Buttons.Ok)
{
_Hint.Value = hint;
_Parameters.Value = JsonHelper.Serialize("");
lbHeader.Text = caption;
lbBody.Text = message;
MessageBoxPopupExtender.Show();
}
protected void OnOkClicked(object sender, EventArgs e)
{
}
}
}
If i set the TargetControlID to a visible control. The ModalPopupExtender still works, but no code behid is called, obviously, preventing me from puting any data in to the fields in the dialog.
Update:
I have testet in a standard aspx page (no masterpage):
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="MessageBoxTestNoMaster.aspx.cs" Inherits="SeceOfC2.TEST.MessageBoxTestNoMaster" %>
<%# Register tagName="MessageBox" tagPrefix="uc" src="~/Dialogs/MessageBox.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button runat="server" ID="TEST" Text="Test" OnClick="TEST_OnClick"/>
<uc:MessageBox runat="server" ID="MessageBox" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
The dialog has been moved to a usercontrol:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="MessageBox.ascx.cs" Inherits="SeceOfC2.Dialogs.MessageBox" %>
<asp:HiddenField runat="server" ID="_Hint"/> <%--Brukt til å vite hvorfor denne dialogen ble kalt.--%>
<asp:HiddenField runat="server" ID="_Parameters"/> <%--Her lagres parameterdata som en Json string.--%>
<asp:HiddenField runat="server" ID="dummy"/>
<asp:Panel runat="server" ID="MessageBoxPanel">
<%--<ajaxToolkit:DropShadowExtender ID="DropShadowExtender1" runat="server" TargetControlID="MessageBoxBorderPanel" Opacity="0.1" Radius="10"/>--%>
<asp:Panel runat="server" ID="MessageBoxBorderPanel" BorderColor="LightGray">
<div class="dialogheader">
<div style="text-align: center; float: left">
<asp:Label runat="server" ID="lbHeader"></asp:Label>
</div>
<div style="float:right">
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Images/Icons/Small/navigate_cross.png" OnClick="OnCloseClicked" />
</div>
<div style="clear:both"></div>
</div>
<div class="dialogbody" style="min-height: 50px">
<asp:Label runat="server" ID="lbBody"></asp:Label>
</div>
<div class="dialogbody" style="text-align: center">
<asp:Button runat="server" ID="OKButton" Text="OK" OnClick="OnOkClicked"/>
<asp:Button runat="server" ID="CancelButton" Text="Avbryt" OnClick="OnCancelClicked"/>
<asp:Button runat="server" ID="YesButton" Text="Ja" OnClick="OnYesClicked"/>
<asp:Button runat="server" ID="NoButton" Text="Nei" OnClick="OnNoClicked"/>
</div>
</asp:Panel>
</asp:Panel>
<ajaxToolkit:ModalPopupExtender runat="server" ID="MessageBoxPopupExtender" TargetControlID="dummy" PopupControlID="MessageBoxPanel" RepositionMode="RepositionOnWindowResizeAndScroll" PopupDragHandleControlID="MessageBoxBorderPanel" DropShadow="True" />
At this point there is no reference to the css classes used so the dialog looks a bit naked, but it works!! I can show and hide the dialog as many times as I want.
Update 2:
Link to the css-file is no problem. Now the dialog looks as it should.
Upate 3:
Tried to move the reference to scriptmanager from masterpage to page. Same result. Does not work.
Update 4:
Removed the refrecence to css file. The message box now works.
Update 5:
I'm not quit there yet but a bit longer than just a few minutes ago.
The problem seems to be connected to the standard asp. web application you get out of the box from Visual Studio 2010 and the CSS file you get located in the Styles catalog. I will try to fiddle a bit with it and maybe I can figure out what is chrasning with the ModalPopupExtender.
After deactivating some more of the classes in the css files
The message box is suddenly placed behind the other stuff in the form and its no longer modal. I can click on any part of the form I want and events geting fired.
Update 6:
I have reproduced the error without masterpage and only a singel styling element:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="MessageBoxTestNoMaster.aspx.cs" Inherits="SeceOfC2.TEST.MessageBoxTestNoMaster" %>
<%# Register tagName="MessageBox" tagPrefix="uc" src="~/Dialogs/MessageBox.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.page
{
width: 960px;
background-color: #fff;
margin: 20px 0px;
border: 1px solid #496077;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="page">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button runat="server" ID="TEST" Text="Test" OnClick="TEST_OnClick"/>
<uc:MessageBox runat="server" ID="MessageBox" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
This is what it looks like without master page and only one style element
The dialog is visible but hiding behind the div with class "page". Hapens after 10 calls to show method. The modal functionality is no longer active and I can click both the ok button in the dialog and the button in the form that is calling the show method.
I was having this same problem with the AjaxControlToolkit 15.4.1 ModalPopupExtender, and what solved it for me was (1) making sure all buttons were in a PostBackTrigger tag, i.e.:
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnDownload" />
</Triggers>
</asp:UpdatePanel>
... and then also (2) removing the "CancelButtonID" property if it existed and using an actual button click or command event to hide the extender.
I wish I could say why this worked, but I don't know enough about the control toolkit to say... hope that helps!

Static Form twitter-bootstrap and Xampp

I have a static form whose code is bellow. Basically I would like to style it with Twitter-bootstrap. Thus I was wondering how to implement it under Xampp. I have placed the bootstrap folder under Xammp/htdocs/MyLocalHostWebsiteFolderName/bootstrap, added a class to the form HTML code but bootstrap was not compiled with the form.
cAN YOU HELP ME BREATH SOME LIFE IN THAT BEATEN UP CODE?
<html>
<head>
<title>Limited Sampling Strategies for AUC estimation</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(".msg_body").hide();
$(".msg_head").click(function(){
$(this).next(".msg_body").slideToggle(600);
});
});
</script>
</head>
<body>
<center>
<form action="form.php" class="form-horizontal" target="results" enctype="multipart/form-data" method='post'>
<h1>Limited Sampling Strategies for AUC estimation</h1>
<table border=0>
<tr valign="top">
<td>
<table border=1>
<caption>Data</caption>
<tr>
<th>Concentrations</th>
<td> <input type="file" name="concentrations" size="20"></td>
</tr>
<tr>
<th>Times</th>
<td> <input type="file" name="times" size="20"></td>
</tr>
<tr>
<th>Covariates</th>
<td> <input type="file" name="covariates" size="20"></td>
</tr>
</table>
<br>
</td>
</table>
</form>
</center>
</body>
</html>
Solved my problem. The form code should call bootstrap library before the HTML code otherwise the CSS classes are not recognized. Putting your form HTML code in the bootstrap folder alone is not enough. The structure goes like this
<!DOCTYPE html>
<head>
<title>Bootstrap 101 Template</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
</head>
<body>
<center>
<form class="form-inline" action="form.php" target="results" enctype="multipart/form-data" method='post'>
</form>
</center>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>

appendChild method isn't working

I am trying to write some appendChild() method but I am stuck here. It seems working but not displaying the result. Not sure what I am missing:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="appendChild().aspx.cs" Inherits="DomExample_appendChild__" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<ul id="myList">
<li>Books</li>
<li>Pen</li>
<li>Paper</li>
</ul>
<button onclick="myFunction()">Click here...</button>
</div>
</form>
<script>
function myFunction() {
var x = document.createElement("Li");
var y = document.createTextNode("Pad");
x.appendChild(y);
document.getElementById("myList").appendChild(x);
}
</script>
</body>
</html>
I am guessing that the script is running correctly, but the form is also being submitted right after and page refreshes to the initial state. Try this:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="appendChild().aspx.cs" Inherits="DomExample_appendChild__" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<ul id="myList">
<li>Books</li>
<li>Pen</li>
<li>Paper</li>
</ul>
<button onclick="myFunction(event);">Click here...</button>
</div>
</form>
<script>
function myFunction(e) {
e.preventDefault();
var x = document.createElement("Li");
var y = document.createTextNode("Pad");
x.appendChild(y);
document.getElementById("myList").appendChild(x);
}
</script>
</body>
</html>
...or you can implicitly define button type as "button" rather than default "submit" type:
<button onclick="myFunction()" type="button">Click here...</button>

ASP.NET MVC 2 - First submit button on site doesn't work - rest is fine!

Sorry for unclear title - I don't know how to describe that problem in one sentence. Code sample will make it clear.
First UP button do nothing when clicked. Rest works like it should!
Below my view:
<%# Page Title="" Language="C#"
MasterPageFile="~/Views/Shared/Main.Master"
Inherits="System.Web.Mvc.ViewPage<GeekClick.ViewModels.HomeViewModel>" %>
<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
<title>Beta</title>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="MainPageLinks" runat="server">
<h2>Najlepsze linki w sieci</h2>
<div id="HomePageLinks">
<%foreach (var link in Model.Links) { %>
<b><%:link.Description %></b><br />
<%: Html.ActionLink("details", "Index", "Link", new {id = link.LinkID}, null) %>
<% using (Html.BeginForm("UpVote", "Home", new { linkId = link.LinkID }, FormMethod.Post)) {%>
<input type="submit" value="UP" /> <% } %>
<%: link.Votes %>
<% using (Html.BeginForm("DownVote", "Home", new { linkId = link.LinkID }, FormMethod.Post)) {%>
<input type="submit" value="DOWN" /> <% } %>
<% } %>
</div>
</asp:Content>
Controller:
[HttpPost]
public RedirectToRouteResult UpVote(int linkId)
{
var updateLink = _geekDb.Link.Single(a => a.LinkID == linkId);
updateLink.Votes++;
_geekDb.SaveChanges();
return RedirectToAction("Index");
}
[HttpPost]
public RedirectToRouteResult DownVote(int linkId)
{
var updateLink = _geekDb.Link.Single(a => a.LinkID == linkId);
updateLink.Votes--;
_geekDb.SaveChanges();
return RedirectToAction("Index");
}
And finally generated html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1">
<title>Beta</title>
<title>
</title></head>
<body>
<form method="post" action="./" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE1NDk5OTQxMTBkZLMRoMOmMkoaJsHIkFWLWjn7HFSzna1LBeMqvRiCxdDQ" />
</div>
<div id ="mainPage" >
<h2>title</h2>
<div id="HomePageLinks">
<b>Something </b><br />
details
<form action="/Home/UpVote?linkId=1" method="post">
<input type="submit" value="UP" /> </form>3
<form action="/Home/DownVote?linkId=1" method="post">
<input type="submit" value="DOWN" /> </form>
<b>Somedesc </b><br />
details
<form action="/Home/UpVote?linkId=2" method="post">
<input type="submit" value="UP" /> </form>10
<form action="/Home/DownVote?linkId=2" method="post">
<input type="submit" value="DOWN" /> </form>
</div>
</div>
</form>
</body>
</html>
There shouldn't be viewstate, should be?
I can't see there any problem in code. Someone can?
Looks like somewhere (perhaps in your Main.Master) you have a <form runat="server" /> that's messing things up.
It makes sense why your first button does not work - notice <form method="post" action="./"> at the top of your output - it's clashing with your other form and posting to the wrong action.

problem with .dll in aspx page

I have added an assembly to my project and then uses the assembly as follows:
<%# Page Title="" Language="C#" MasterPageFile="~/Global.Master" AutoEventWireup="true" CodeBehind="Calendar.aspx.cs" Inherits="Permias.Calendar" %>
<%# Register TagPrefix="ec" Namespace="ControlSample" Assembly="EventCalendar" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div id="content">
<div class="post">
<ec:EventCalendar runat="server" ID="eventscalendar" DataSourceID="sqldatasource1"
BorderWidth="0" DayField="starttime" ShowTitle="true" CssClass="eventmonthtable">
<DayHeaderStyle CssClass="caldays" />
<DayStyle CssClass="calcurrentmonth" />
<TodayDayStyle CssClass="calcurrentday" />
<WeekendDayStyle CssClass="calweekend" />
<OtherMonthDayStyle CssClass="calothermonth" />
<DayNumberStyle CssClass="dayNumber" />
<HeaderTemplate>
<table width="100%">
<tr align="center">
<td>
<asp:LinkButton ID="PrevMonth" runat="server" Text='<%# "« " + Container.PrevMonth.ToString("MMMM yyyy") %>'
CommandName="PrevMonth" />
</td>
<td>
<h3>
<asp:Label ID="label2" runat="server" Text='<%# Container.CurrentMonth.ToString("MMMM yyyy") %>' /></h3>
</td>
<td>
<asp:LinkButton ID="NextMonth" runat="server" Text='<%# Container.NextMonth.ToString("MMMM yyyy") + " »" %>'
CommandName="NextMonth" />
</td>
</tr>
</table>
<div class="dashedline">
</div>
</HeaderTemplate>
<DayEventTemplate>
<div style="padding: 3px;">
<asp:HyperLink ID="HyperLink1" runat="server" Text='<%#Eval("title") %>' NavigateUrl='<%# "Events_view.aspx?Eventid=" + Convert.ToString(Eval("ID"))%>'
ToolTip='<%# SharedRoutines.truncate((string)Eval("description")) %>' /></div>
</DayEventTemplate>
</ec:EventCalendar>
</div>
</div>
</div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="splash" runat="server">
<div id="splash"> </div>
</asp:Content>
However it generates an error saying that:
Compiler Error Message: CS0103: The name 'SharedRoutines' does not exist in the current context
Why is this?
You need to include the namespace containing the SharedRoutines class at the top of the page, like this:
<%# Import Namespace="Your.Namespace" %>
You can also include it globally in Web.config:
<pages>
<namespaces>
<add namespace="Your.Namespace" />
</namespaces>
</pages>