Showing posts with label masterpages. Show all posts
Showing posts with label masterpages. Show all posts

Monday, March 26, 2012

AJAX Toolkit not working with Masterpages when retrofitting to exsiting website and what i

I have posted to these two threads with no response

http://forums.asp.net/p/1096452/1761461.aspx#1761461

http://forums.asp.net/p/1037436/1760268.aspx#1760268

Please scroll to the bottom of those threads for more details, but in a nutshell I must be having a different problem than there's as they seem to have all had problems with beta versions and I am on VS 2005 SP 1 and AJAX 1.0.

I have no problem creating a new AJAX enabled web site and getting it to recognize and use the controls, but when I try to AJAXify an exisiting website the toolkit does not work. If I only add script manager and a panel, I get no errors, but then if I try to add any of the extenders from the toolkit, the project won't even compile - get the squiggly lines underneath the control, but I still have intellisense in the update panel, but not the calendar extender, which it claims is not a known element.

With Master Pages, where do you put the script manager, in the Master page, or the child pages?

Notes below are added after the original post

OK, I created a new AJAX enabled web site from scratch and then added a master sheet, deleted everything except the following from my default page after wiring the MAsterPAgeFile reference

<%@dotnet.itags.org.PageLanguage="VB"MasterPageFile="~/MasterPage.master"AutoEventWireup="true"CodeFile="Default.aspx.vb"Inherits="_Default" %>

<%@dotnet.itags.org.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="cc1" %>

then I added a script manager, and then a textbox and calendar extender inside an update panel, and ran the debugger. Right away it popped up a dialog box wanting to know where the ExtenderControlBase.cs file was, and so I browsed to it in the subsequent ASP and then AJAX directories, found it and then ran this project and it worked fine. Problem is I didn't need to find and browse for that ExtenderControlBase.cs file to get this project to work before I added master pages..?? And why does it continue to work eventhough I have since removed that file from the project?

Nevertheless it still does not work in my original website that has far too much work put into it to try and start over from scratch. This is the error I am getting:

Error 1 Element 'CalendarExtender' is not a known element. This can occur if there is a compilation error in the Web site.

and I get

Error 34 Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.


usually people don't like to reply because: some people post too much information that readers do not want to go over everything ... time is valuable. if you can make it short and precise then you will get more help.

...

do you have your AjaxControlToolkit.dll inside your bin?
From your other threads, you said that when you create a new ajax site it works, but your existing website with ajax doesn't work? May be you didn't copy the web.config file correctly.

if you want to add ajax to a non-ajax website; first, you create a new ajax site and copy the web.config file over to your old website. be sure to back up your old config file and move over the data that you need to the new config file. Good luck ......


Thanks for replying Wishstar,

Yes, I have taken over a web.config just as you said. I did it twice. The only diff in the web.config is that the old one had a connection string. I went along step for step with the video tutorial. And yes AjaxControlToolkit.dll is inside my bin.

The only other apparent differences is that my exisiting website has Sql dataset connections, and is also being developed on a remote machine, but the VS 2005 and all my AJAX stuff is on my local machine, but my source code and database is on a remote machine. Everything has worked fine up until now.

It seems nothing in the toolkit is recognized. I also tried reregistering (re-adding a reference to) the dll, and it even recognized that it was already registered and warned it would be overwritten.


sorry ...accidentally double posted


does anything run on your system at all? any of the samples from the toolkit? Try running it on your dev machine. if you are able to run the samples, that means there must be something wrong with your work.


OK solved part of problem found MUCH BIGGER PROBLEM

Sorry I haven't responded for two days, but I was on jury duty and just got back to debugging this problem.

I ruled out my coding as the problem by taking my code from the working exisiting web site and using the Visual Studio copy web site tool, copied the develoment files to an AJAX toolkit enabled website that I juts created on my local machine.

All extenders started working and intellisense returned UNTIL I WENT TO PUBLISH TO THE REMOTE MACHINE.

The publishing went apparently fine until I went to pull up the web site ...I got a cryptic error and then remote desktopped into that machine and ran the local host to get a more verbose explanation of the error.

It seems that it does not like anything to do with the System.Web.Extensions or System.WebServer. I had to remove all the AJAX stuff and line by line comment out these lines from my web.config and rebuild before my website was working again...PHHHEWWW (I got a demonstartion meeting this afternoon and people will want to review my site between lunch and the meeting - I told them to).

The following is a screen of the error I got while running the local host...what do I have to do to the remote host running IIS to get it to allow me to run AJAX on it?

Thanks, Earl

Server Error in '/' Application.

Configuration Error

Description:An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message:Could not load file or assembly 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. (c:\inetpub\wwwroot\web.config line 52)

Source Error:

Line 50: </httpHandlers>Line 51: <httpModules>Line 52: <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>Line 53: </httpModules>Line 54: <!--


Source File:c:\inetpub\wwwroot\web.config Line:52

Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210


did you install ajax on your server?


OK, paint me stupid...am I supposed to install AJAX on my server too? I'm confused, I thought AJAX toolkit was a set of controls that generated script. I guess I am thinking way too much like the VB6 hack that I am (guilty as charged) and controls are just like ocx's.

Ok, so do I install AJAX toolkit? AJAX normal that came with the script manager, er?


OK problem solved...at least so far. This is what I posted in this other threadhttp://forums.asp.net/t/1072841.aspx?PageIndex=2

On my development machine, I clicked on the .Bin folder and then clicked on Add Item, and NOT Add Reference. I then browsed to the folder where ASP.Net extensions folder and then clicked the folder of my version number v1.0.61025 and NOT the AJAX Control Toolkit. In that version numbered folder you find the System.Web.Extensions.dll. The dll now appears under the Bin folder. I merely published to my remote (nearby Windows 2000 SP4, .Net Framework 2.0, IIS 5.0 or 5.1? box) webserver (intranet).

Now, my only question, am I running the minimum configuration to allow the ASP AJAX services? Also, was I oblivious to this trust issue. As I understand a host (other than intranet?) has to support AJAX, but it seems I got around that issue?


Hi,

FYI

Just keep in mind when you want to host your application make sure that your hosing company support ajax as well. I had this promblem and I had to ask them to install the framwork on their server.


Lucky for me I'm just an Intranet kinda guy, but I imagine some day I will be on the Internet, and I'll have to learn this all over again. BTB I am on a LAN and using a Windows 2000 SP4 server running IIS 5.0 with a 'shadow' IT group (yep, they really call it that) and I may have to move it to the official IT group (dark side, black helicopters), and I don't think they are AJAXified or willing either.


I have this similiar issues. I installed AJAX on my local machine. I have to create a reomote project, I can't install AJAX on the reomote Server because I'm not allow. But I did, copy all the .dll related to AJAX and AJAX control and the Web.config has all the stuff need. When I build the project I get erros on every control that I'm using, sample "Element CalendarExtender is not a known element" If I go to the http link, everything seams to work fine, but I can build the project because of the elements errors.

How can I fix this issue?

Thanks


Please look at my answers above, and then follow the link in my response as to how I solved the issue.

If your issue is that you cannot install AJAX because you are publishing to an ISP (commercial third party Internet Service Provider) then you need to ask them to install it, and they should comply, most people are doing this.

If you are publishing on an Intranet or a captive network for lack of better terms, then you will probably at least need to get administrative rights on that server and then publish while properly referencing the AJAX toolkits, and the System.Web.Extensions.


It's on an Intranet and they will not install anything and they wouldn't give us Administrative rights. I was trying to work around the issue by adding the System.Web.Extensions.dll and AJAXControlToolkit.dll to the bin folder. Sad

Thanks


How do you publish to it normally?

Saturday, March 24, 2012

AJAX Timer not Ticking in MasterPages

Hi,

I have a timer control of the new AJAX version released. When in a page that doesn't have any MasterPages the Timer works perfectly, however when you give a MasterPage to the Page the Timer never Ticks!!!... I put a ScriptManagerProxy in the aspx page and a ScriptManager in the MasterPage (followed exactly the example on this site), but still to no avail.

why is this ? is this a bug ? am I missing something else ? anyone encountered something the sort?

Thanks!

Can you post some code which doesn't work? What is a purpose of the ScriptManagerProxy? I wrote a simple example for Timer and master page and I didn't find any problems.

<%@. Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
CodeFile="Default2.aspx.cs" Inherits="Default2" Title="Untitled Page" %
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:Timer ID="Timer1" runat="server" Interval="5000">
</asp:Timer>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" OnLoad="Load_Some_Data" UpdateMode="Conditional">
<triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" />
</triggers>
<contenttemplate>
<p>Refresh number: <asp:Literal ID="lit1" runat="server">0</asp:Literal></p>
</contenttemplate>
</asp:UpdatePanel>
</asp:Content>

public partial class Default2 : System.Web.UI.Page
{
protected void Load_Some_Data(object sender, EventArgs e)
{
lit1.Text = GetSomeNumber();
}
private string GetSomeNumber()
{
int i;
if (!int.TryParse(lit1.Text, out i))
return "ERROR";
else
return (++i).ToString();
}
}


Hello and thanks for the reply..

Try this: the Timer has to start Disabled and Enable it at runtime by a click event or so... also I'm seeing you don't have a Tick event!?


Here is a solution when Timer is by default disabled and during runtime enabled. I don't have tick event because updatepanel is refreshed every 5 seconds and on every refresh method Load_Some_Data is executed. What are you doing in your tick event and it can't be done this way?

<%@. Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:Timer ID="Timer1" runat="server" Interval="5000" Enabled="false">
</asp:Timer>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" OnLoad="Load_Some_Data" UpdateMode="Conditional">
<triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" />
</triggers>
<contenttemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<p>Refresh number: <asp:Literal ID="lit1" runat="server">0</asp:Literal></p>
</contenttemplate>
</asp:UpdatePanel>

<asp:Button ID="Button1" runat="server" Text="Enable Timer" OnClick="Button1_Click" />
</asp:Content>

public partial class Default3 : System.Web.UI.Page
{
protected void Load_Some_Data(object sender, EventArgs e)
{
lit1.Text = GetSomeNumber();
TextBox1.Text = lit1.Text;
}
private string GetSomeNumber()
{
int i;
if (!int.TryParse(lit1.Text, out i))
return "ERROR";
else
return (++i).ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
Timer1.Enabled = true;
}
}


hey thanks bsebo for following my case...

currently I don't have my code in front have to get home. 3hrs more :\....

basically the situation is this: A ScriptManager in the MasterPage, ScriptManagerProxy in the Page. A disabled Timer on the Page and on Button click event is gets Enabled. Ok it gets "Enabled" BUT the Tick Event is never executed.. .while without a MasterPage it gets executed. I need to work with the Tick event as I'm doing some process on the Tick event and thats it! ... I will post the code when I get back home.

Thanks again!


<%

@.PageLanguage="C#"MasterPageFile="~/MasterPage.master"AutoEventWireup="true"CodeFile="Default2.aspx.cs"Inherits="Default2"Title="Untitled Page" %>

<

asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server"><asp:ScriptManagerid="ScriptManager1"runat="server"></asp:ScriptManager><asp:UpdatePanelid="UpdatePanel1"runat="server"><contenttemplate>

<

asp:Buttonid="Button1"onclick="Button1_Click"runat="server"Text="Start"></asp:Button><asp:Labelid="Label1"runat="server"Text="Label"></asp:Label>

</

contenttemplate><triggers>

<

asp:AsyncPostBackTriggerControlID="Timer1"EventName="Tick"></asp:AsyncPostBackTrigger>

</

triggers></asp:UpdatePanel><asp:Timerid="Timer1"runat="server"Enabled="False"Interval="5000"OnTick="Timer1_Tick"></asp:Timer>

</

asp:Content>

public

partialclassDefault2 : System.Web.UI.Page

{

protectedvoid Page_Load(object sender,EventArgs e)

{

}

protectedvoid Button1_Click(object sender,EventArgs e)

{

Timer1.Enabled =

true;

Label1.Text =

"Timer started";

}

protectedvoid Timer1_Tick(object sender,EventArgs e)

{

Timer1.Enabled =

false;

Label1.Text =

"Timer stopped";

}

}

Hi, I'm back, managed to post the code... as you can see the Page has a MasterPage. ... while this peace of code works in a Page without a MasterPage...with a MasterPage it would start (or seem to be Enabled) but would never Tick. This is a bug for sure.... I'm testing right now with many possibilities but neither would work..

In fact something really weird and shows more that this is a BUG... is that when on debug the Timer is set to Enabled it will start Ticking but not when started from a Button.

bsebo you have to provide an example similar to what I said... thanks but yours is not what I want... bsebo try doing it with a Tick event ;)... your not using the Timer properly.

Thanks! martin


You right, it doesn't work. If you put the Button1 outside of the UpdatePanel1 then it can enable the Timer1. But, if you put it inside of the UpdatePanel1 then it can't. It seems like a bug because when you look at a:

<script type="text/javascript">
<!--
Sys.Application.add_init(function() {
$create(Sys.UI._Timer, {"enabled":false,"interval":5000}, null, null, $get('ctl00$ContentPlaceHolder1$Timer1'));
});
// -->
 enabled is always set to false.

</script>


It doesn't work yes... but are you sure because of that? I tried on a Page without a MasterPage and viewed the source while a Timer1 was enabled... it still showed that it was "enabled":false.

There's sure a bug... I hope some from the ASP team reads this!

I cannot quite get a grasp on what's happening.. why should a MasterPage conflict that much?

Thanks!


Hello so is there any work arounds?... or have to wait for the fix?