ASP.NET Menu control changing position after postback - c#

I am currently testing a menu in ASP.NET I've recently made using asp:menu control.
The menu is just as I want it to be right now, but whenever there is a postback that updates the whole page, it moves a little downwards (only once, a second postback won't move it a little bit more).
It's not CSS - > I've removed all CSS from this menu)
It's not any property -> I've commented out everything related to customizing the menu
It's not any other element above it enlarging -> I've specially put it inside a table, in which the only content is the asp:menu control
It moves a lot downwards in IE6, a little in IE8, and it doesn't move at all in Firefox 4.
What could I do ? Are there any alternatives ? Is there any property I can use, or any outer element I could put it inside in order for it to stay still ?
And yes, every single machine this is going to run in is using Internet Explorer. The nightmare of any web developer.
---[update]-----
I've built a menu in a separate project, and the effect wasn't there! I've copied the exact same files into my project, and ran it, and the issue was there.
Could it be a difference in the asp.net version ?

Did you check using IE web developer toolbar to see what's the html looks like in that area before and after the postback? It seems more like a browser issue so the toolbar would give you details as what is coming in the gap or may be what's pushing it down.

If the app is in asp.net 4.0, look at the source code of the page after it renders the first time, and then after the postback. Make sure it renders as divs on both or tables on both.
I currently have a similar issue where my menu "spreads out" on the postback. Before the postback, it renders divs. After the postback, it renders tables.
There is specifically a property on the menu "RenderingMode" which is suppose to control this, but it is not working for me.

I had the same problem. My navigation menu sits in an UpdatePanel, and I changed the UpdateMode from Always to Conditional - problem solved. This was in my master page.

Related

How do I move items freely in Visual Studio 2019?

I'm new to editing web pages on ASP.NET webforms and is currently exploring, whenever I add items, they are always added on top left and I can't move it to center, I just want my button to be at center.
I'll use my website for school purposes only and most likely will be disposed after some 2 years, that's why I used webforms instead of MVC because this is a short-lived project
How do I move it freely?
I'm not too sure what you mean, however, I will try and provide a solution.
Unfortunately, because of a bug, the menu is disabled for and based controls. To enable the menu, add style=”display:block” to labels or hyperlinks. This will be fixed in the next service pack. You can then use the Position dialog to set positioning mode:
https://devblogs.microsoft.com/aspnet/absolute-and-relative-positioning-in-visual-web-developer-2008-designer/
this is a good website to help you.
Go to .aspx Source page and modify the control's style like this:
style="position:absolute; top: ...; left: ...;"
Now you can drag it to anywhere you want. But setting the position of the control programmatically is a better choice.

JavaScript generated web page issue

I have a problem with javascript generated web page. I have a web page on the internet that is generated by javascript. I am working on changing a web page using wpf web browser control. I have to make some changes to the web page by inserting jquery, and changing css and hiding some elements.
Here is the issue.
Application works ok most of the time, but sometimes, for reasons unknown, it does not change the css or hides the elements. I presume that it has something to do with the javascript that actually generates the page. My code is executed, but no changes are made, so I presume that the script cannot find the elements in the page because they do not exist in the page, at the time of the execution of my scripts. This is just an assumption.
I need help resolving this issue. I have tried delaying the execution of my scripts for n seconds, waiting for body.ready, document.ready and window.ready, but nothing helped. Also, I use wpf web browsers LoadCompleted event, but... From time to time, the script simply makes no effect on the page. Did somebody have this issue, does anyone have any idea how to solve it?
Thank you very much in advance...
When building single page apps, always use a framework like Backbone or Sammy.js together with Mustachejs (or Hogan.js) for templating.
Since we don't have any code to look at, if you're using jQuery, I suggest you check out .live() and .on() for attaching event handlers to elements you plan on loading into a div (making them clickable) etc.

Telerik chart not loading correctly (ajax/script issue?)

I have a page which contains user controls with Telerik Charts (grids also, but they work fine). From this page, the user can click on a button to be redirected to a "Printer-Friendly Version" type page, which opens a new window via javascript and goes through a slightly different view (for formatting and stuff), but the telerik code is all the same.
The problem is, my Chart displays just fine in the original window, but the new window displays basically an empty chart with no data. This bug is only present in IE, and only applies to Charts. Grids work fine, for whatever reason. I'm thinking this is due to differences in script caching between browsers -- correct me if I'm wrong, I'm semi-new to client-directed web development.
Anyway I read somewhere that Telerik has issues with loading data and/or js files when loaded via ajax, so maybe that's the problem? If so, how could I get around this? And if not, any ideas on what could be causing this issue? It's causing me a great deal of frustration, since a print preview page seems like it should be the easiest of jobs.
Edit:
The charts are being rendered as html (if somebody can explain how to render them as images, that would be awesome). And dev tools shows basically the same thing between chrome and IE. Whenever my web service goes back up ill WinMerge them and look for any peculiarities/differences between them. In the mean time, though, the "render as an image" concept sounds promising. That way I could just save the image from the first page, and insert it right into the print preview page, right?. And since it's a print-preview page, it's not going to need to be interactive or anything, so that'd work out nicely.
Another (important) Edit:
These are probably the culprit...
And here is a little more detail on that:
And here is a side-by-side of it working(in chrome) and not working (in IE):
Have you considered using a print-specific stylesheet instead, e.g.
<link rel="stylesheet" type="text/css" media="print" href="print.css" />
In which you specify the styling to apply when printing.
That way, you avoid reloading the page (duplicate database hits, etc.) and don't need to delve into the AJAX of Telerik's controls.
EDIT:
Regarding using an image rather than HTML, first make sure you won't lose any features/detail, then check out the .Save() method of the RadChart control. You could either save it to a memory stream, or if you want to re-use the image save it to a directory on the webserver and clean it up periodically. That way, you can just point your print version to the image and not re-generate it.
This Telerik forum post may be of use.

Strange behavior in ASP.net regarding WebControl vs UserControl ViewState

Ok, I've solved my problem but I don't know why one type of control works and another doesn't.
The scenario: I'm working on a custom wizard style page design that was originally done completely with UserControls in C# ASP.Net 4.0. The step that you are viewing is controlled on server side via control visibilty.
My problem: I dislike the UserControls and want to use WebControls as much as possible, though it's not worth my effort to redo the entire thing with WebControls, and new controls are needed to expand the functionality.
My original solution: I initially started creating WebControls as needed. This worked fine until I got 2 steps away from a given WebControl, where it lost it's ViewState. At least I believe that is what happened. It was a CheckBoxList and as soon as I was 2 steps away, the ListItems disappeared.
The final solution: Recreating the same control as a UserControl I always have access to the CheckBoxList Items.
This all seems fairly logical. If a control or one of it's parent's is not visible, it won't be included in the ViewState data. I guess the real question is, why does UserControl work?

Creating xaml 'template' for multiple pages

I'm developing a Silverlight application for the first time. I've gone through some tutorials, but I can't seem to find anything that helps me with this particular problem. I would like a set of buttons to be present on all of my pages (like a template). When a button is pressed, I would like the ContentGrid to slide out and a new ContentGrid slide in (with the relevant .xaml file being loaded).
Are there any tutorials showing the best way to do this? From samples I've seen, they only seem to transition between two pages, so copy-pasting the group of buttons on each xaml page isn't too much of a problem. However, with more pages, it would be inefficient to copy-paste the base layout each time.
Thanks for any suggestions
I used to create a master view and create each page content as a user control; that way, I can swap out/in the user control for the appropriate page, and I would have a consistent header that way... similar to a master page in ASP.NET. I'm sure there are other templates too; I'm not aware of everything available for Silverlight...
The one answer I cannot provide is the transition; the only thing I can offer is Telerik has a control for that purpose, the transition control: http://demos.telerik.com/silverlight/#Controls I understand if you can't drop a couple of hundred bucks to get it though :-)
HTH.
Have you tried the Silverlight Business Application Visual Studio Project template?

Categories