Browser scrollbars in ASP.net (how to set them) - c#

How do I set the scrollbars in an ASP.net page dynamically? When a user comes to certain pages on my site I would like the page to be scrolled down about halfway. Is there a way to do this without using Javascript?

One standard HTML option is to set a target <a name="foo"></a> on your page. Links to the page would need to be /yourpage.aspx#foo, but that would cause the browser to scroll to the target.

Sounds like you're looking for an anchor tag. You specify the URL as www.site.com/page.aspx#middle
Then in your page, you put the tag where you want them to scroll to
<a name="middle" />
http://www.w3schools.com/tags/tag_a.asp

asp.net is a server side technology so it is not possible to manage the scroll position without using javascript. At least I have not seen it done.

Something you might be interested in that I've used successfully on projects before is the smartScroller. You can place this control on a web page and the web page will automatically remember the scroll position between postbacks and scroll there. Check it out: https://web.archive.org/web/20211020140248/https://www.4guysfromrolla.com/articles/111704-1.aspx
It does use javascript though. Any reason in particular you don't want to use javascript?

Related

How can I load page content with freeze header on postback?

I'm using asp.net and c#.net.
I'm gonna implement a website that has content navigation like that Microsoft did on this link:
Microsoft Windows
In this link you're able to browse page content with freeze header on postback
and also you're able to browse videos from left Navbar without page postback.
The important thing is for each click url is changed.
Any ideas or help would be appreciated.
Thanks and regards
First off, to clarify, postbacks are only required if you're submitting form elements. If you're creating a webforms application, you can easily use controls like HyperLink with a NavigationUrl to navigate among URLs without needing postbacks.
If what you mean is that you're seeing the page partially updating when following links, that's not what I'm experiencing. The pages appear to completely reload when the links in that page are clicked. In your own site, you can use AJAX and JavaScript to implement a navigation system that doesn't require heavy navigation requests. Look at Manipulating the browser history (MDN) for information on exciting new JavaScript features that will let you modify the browser's URL/history without reloading the page. There are several JS libraries that integrate with this feature to give you "AJAX" navigation capabilities.
To simply get the header to not scroll along with the rest of the page, use position: fixed in the CSS for the element.

ASP.NET Menu control changing position after postback

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.

How to add IFRAME in SilverLight?

How do I add IFrame in a Silverlight 4.0 User control ?
And I want a button on the control that refreshes the IFrame. Is that possible?
To render HTML on top of silverlight, you have to use WindowLess mode. This is a configuration in the object tag. Then you'll need to manually program your IFrame to float in the correct location using javascript or the bridge provided by Silverlight. You can use a commercial control like Robaticus suggested or figure it out on your own.
Either way, none of these options work for Mac. So if you're developing for Windows only, then you're ok. Anyone using Mac will not see any HTML float on top of Silverlight.
If you absolutely want an IFrame in the HTML page (contrary to what the other answers suggest) you could obtain access to the IFrame in Silverlight by using the HTML Bridge
I think you can use WebBrowser class to display IFrame content in Silverlight. Or check this link it will also help you. - How to use iFrame tag in XAML Silverlight 4?
The iframe tag is HTML, not Silverlight. If you have an out-of-browser Silverlight application, you could potentially use the WebBrowser control, but this is not available for in-browser applications.
There is an approach out there where you can essentially make a DIV on your hosting page appear overtop of your Silverlight application, but, in my experience, this is very hard to control, and the visual results are less-than-ideal.
Additionally, there are a few commercial components that do HTML rendering, but they all seem to use the same approach of a floating DIV, and they are not as reliable as I would like to see them.

Asp.Net Wizard in ASPxCallBackPanel control

Im using ASPxPopUpControll in which I have ASPxCallBack panel. THis CallbackPanel was embeded there because I wanted to have solution based on callbacks despite of reloading page each time.
In this CallBackPanel I've embeded asp:Wizard control.
What I want to achive is get rid of postbacks after clicking next previous etc buttons in this wizzard.
Any hints?
Maybe there is other way to create nice wizard without any postbacks ?
thanks for help
The ASPxCallbackPanel cannot intercept postbacks and "convert" them to callbacks as the MS UpdatePanel does this. So, a possible solution is to replace the ASPxCallbackPanel with the MS UpdatePanel and use the Wizard inside it. One more solution is to use the ASPxPageControl, position all required controls in its Pages and manage them manually.
I would recommend looking into ajax and jquery for asynchronous postbacks, that way you don't get a page refresh and you would only need to update a smaller part of the ui.

How do I implement simulated frames in ASP.NET MVC?

How do I implement a simulated frameset in ASP.NET MVC without running afoul of browser differences?
If possible, I would like a header and two vertical panes. The header will be pinned to the top of the browser. The left pane will contain an index of some sort, and the right frame will contain content. Each of these panes can have its own scrollbar, but only if the content is long enough to require it.
It should look similar to this: http://msdn.microsoft.com/en-us/library/w0x726c2(loband).aspx
NOTE: I do not need to support IE6, but I do need to support IE7 for awhile.
You could try the jQuery splitter plugin.
http://methvin.com/splitter/
Use CSS Layouts. Some examples: http://layouts.ironmyers.com/

Categories