I have a problem that appeared after it was working successfully for days.
I am running DNN 7.2.2 locally under dnndev.me.
I have a module with a main public view. In that view I define the NavigateUrl for three hyperlinks to target different module controls.
here is how i declare the hyperlink urls:
AddProductLink.NavigateUrl = EditUrl("AddProduct")
ManageOrdersLink.NavigateUrl = EditUrl("OrdersManagement")
ManageStoreLink.NavigateUrl = EditUrl("StoreManagement")
The AddProductLink and ManageOrdersLink work perfectly, and the ManageStoreLink has been working for days wihtout trouble.
Now, all of a sudden, the ManageStoreLink is no longer working. The ManageStore Module control is an ascx usercontrol.
What happens:
When I click the hyperlink for the ManageStoreLink, the page_load event of this usercontrol is called and executes without error, but then the home page of the website is loaded (http://www.dnndev.me) instead of the module control url (http://www.dnndev.me/ModuleDevelopment/KrisisStore/tabid/1106/ctl/StoreManagement/mid/2601/Default.aspx).
Question
How can I figure out why the module control is not showing OR why it redirect to the home page after the module control loads?
There are no errors generated in the event viewer and I can debug and step through the page_load events (which happen in this order) of the StoreManagement.ascx, login.ascx, user.ascx, and default.aspx and I do not see any redirects getting called.
Okay,
after totally re-writing my user control I realised that one of the asp:requiredfieldvalidators was referencing a textbox that did not exist. Once I fixed this, the problem went away.
The frustrating thing is that there was no error shown and no error created in the event log. It took quite a while to narrow this down.
Related
I thought including ajax control toolkit is a simple thing, but for some odd reason it's not working. It always triggers a full postback from a button inside UpdatePanel.
I am using VS 2015 / asp.net 4.6.1 / Class Library output type. ajaxcontroltoolkit.dll v18.1.1 is added via Nuget. I created a very basic web form page with only an update panel and a label outside of it. Clicking on a button inside update panel always causes a full post, updating the label outside along with it.
Oddly enough, I created a blank Web Site project with the same page and code behind, and it works fine as expected there.
I use browser debugging tool to observe the network output. The site that works appears to have 1 reference to WebResource.axd and 2 references to ScriptResource.axd. Versus the site that doesn't work having only 1 reference to Scriptresource.axd and none to WebResource.axd.
Is there something I missed? Any further techniques I can use to troubleshoot the problem?
One full day of trouble shooting. This setting in web.config prevents ajax control toolkit from performing partial page load.
https://weblogs.asp.net/scottgu/gotcha-don-t-use-xhtmlconformance-mode-legacy-with-asp-net-ajax
I have a DataGrid control that refuses to reload itself from View State on Postback. I've traced this all the way back to the Load event on the control. It just flat refuses to reload from ViewState. It just doesn't do it.
The control is situated like this:
Webform
--> Dynamically loaded User Control (via "LoadControl")
----> Statically placed User Control
------> DataGrid
Yes, I know it's a little convoluted, but all the other controls on the page are reloading themselves, except for this DataGrid.
I've tried all the usual suspects --
The Control Tree is the same on page load and postback.
I've tried setting TrackViewState as well. That didn't do anything either.
Now, this is the weird part: this worked fine, then broke. I've gone back through Subversion and reviewed all the code changes for the last month, and there's nothing that would have changed this.
This makes me wonder if this can behavior somehow be affected from some external variable -- something external to the code. Is there some setting or something that might change how this behaves?
Are you hitting the issue where the control isn't actually present when its doing the load from ViewState? http://msdn.microsoft.com/en-us/library/ms178472.aspx
i was working on a vb.net project and i couldn't find some controls in the code-behind file(*.vb). i was wondering is it because i was working in page_load function so controls are not loaded until after page_control event. however i was able to find them with findcontrol function of formview objective.
Controls inside of templates (such as in your FormView, or in a GridView) are not directly accessible in the code behind. You must use FindControl to get access to those controls.
If the controls are declared in the aspx then they're defined in partial class equivalent for your Page class.
This was introduced along with .Net v2.0 so that messing with the designer wouldn't screw up with your code behind file (which caused quite a few problems in some cases).
You can access the controls from your Page Load event. Sometimes IntelliSense plays tricks on you and doesn't suggest the control. Just type it in. It will work. You can close the aspx page and open it again. Sometimes that fixes it. Or just restart Visual Studio if you're annoyed by it.
However, there are a few considerations if you are interested in accessing control data at certain times during the life cycle of the page.
Server controls have their own life cycle that is similar to the Page life cycle, but the order in which the event is triggered for the controls is as follows:
Init and Unload event for a control occurs before the event is raised for the container (bottom-up).
Load event for a control occurs after the event is raised for the container (top-down).
You can find a more detailed explanation of the Page life cycle events on MSDN.
It's hard to tell what exactly the problem is; it would help if you could post some code here.
I do have two guesses/suggestions:
If you have the problem that brentkeller is describing, what usually fixes this completely for me is deleting the aspx.designer.cs file, then right-clicking on the .aspx file and select "Convert to Web Application". This re-creates the designer file.
The control is inside a template like Jason Berkan suggested. If it's in a LoginView, for example, you would use .FindControl("controlId") on the LoginView.
The controls would be part of a partial class in the same solution. Just find all references for your class name.
I occasionally have trouble with adding a control to a page and the Intellisense not recognizing the control. The compiler also seems to not recognize the control and prevents the project from being compiled. It can be very frustrating and I really haven't figured out why.
Sometimes it helps to close the aspx page and its code file, sometimes closing Visual Studio and re-opening it works. Sometimes none of it works and I just try another way to get things done.
I don't know if this is what you're experiencing, but if so, it can definitely make you scratch your head and wonder what is going on.
In Sitecore 6, I have created a sublayout that has an asp:login control. For some reason, it doesn't work when I add it to the layout of a page. The page simply posts back, but doesn't log me in.
I made a stand alone .aspx with a login control and it works fine. So the problem is not with the membership system. My guess is it has something to do with the page life cycle and event ordering. Maybe the login control is not getting added to the page in time to handle the correct events and data?
Does anyone know why the login control would not work when added as a sublayout? Does anyone know a work around?
UPDATE
I hooked up event handlers to the controls events, and for whatever reason, they never get called. The control's onload method does get called, but the LoggingIn and Authenticate events never fire. This could still be due to my wrapper control not being added to the page in time. However, I think that they have other controls that do similar things, so I'm still not sure what I'm doing differently/wrong...
Try adding the login control definition to the typesThatShouldNotBeExpanded list in web.config:
<rendering>
<typesThatShouldNotBeExpanded>
<type>System.Web.UI.WebControls.Repeater</type>
<type>System.Web.UI.WebControls.DataList</type>
</typesThatShouldNotBeExpanded>
</rendering>
I have a web site in asp.net that uses a master page. In this master page I have a multiview control with one view that has all the content for the content pages and one view that has some local content to the master page where I show error messages from all content pages.
In this error view I have a asp.net Label control that displays the error messages. Usually the label works fine, but in some few cases the label is null, which renders a NullReferenceException. Now I have handled this case by checking if the label is null before using it, but still my question is:
Why is this label null? What are the circumstances that can generate this?
EDIT: In the master page I have a method called SetErrorText that takes a string and sets the label. I'm calling this method from the content pages' Page_Load method, and this generally works fine. In all but two cases (that I've discovered so far) the label is initialised, and nothing separates these two cases from all the ones that work.
Also, all other controls in the master page are initialised, such as the View-control that houses the label.
When the Page_Load of a content page rolls around, the master page should be populated.
It seems that the problem was one of sloppiness. Someone had forgotten to delete the auto-generated Content-controls that Visual Studio throws in on all content pages where the master page has a ContentPlaceHolder-control.
If a content page has a Content-control, all controls that are placed in the ContentPlaceHolder-control on the master page will be null, it seems.
What method on the master page are you accessing the label from? Depending on the stage of the page lifecycle, the label control may not have been loaded yet
Could you be accessing it before it is created? Check the page lifecycle: http://msdn.microsoft.com/en-us/library/ms178472.aspx
I had a very similar error. In my case it was caused by .NET compiler wierdness related to the control designer file. Even if the designer file has the controls defined correctly, delete it, re-generate it and rebuild (make sure to rebuild, don't just 'build'). See the top answer here for how to do regenerate the designer file:
How do you force Visual Studio to regenerate the .designer files for aspx/ascx files?