Save position on site after postBack in asp.net 2.0 - asp.net

Is there any easy way to save users position on the site after postback ?
using maintainScrollPositionOnPostBack="true" in my web.config pages section doesnt work.
I mean it does work but only in ie. Is there any way to make it work on firefox and chrome ?
thanks for any suggestions

Koder Gurl had the same type of problem back in 2010. She posted the code that was giving her trouble and from the sounds of it, she had the browser issues you are having.
Try looking at her solution at this page: http://www.kodergurl.com/2010/08/maintain-scroll-position-on-post-back.html
I hope that will help you.

This can be done in different ways as below:
a. Set MaintainScrollPositionOnPostback property to true in Page directive for specific page(s).
<%# Page Title="Home Page" Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default"
MaintainScrollPositionOnPostback="true" %>
b. For whole site, add below section to web.config file.
<configuration>
<system.web>
<pages maintainScrollPositionOnPostBack="true" />
</system.web>
</configuration>

Related

How do I find out where .aspx page is pulling its header?

I haven't worked with C# or ASP.NET before, but I'm trying to update some .aspx pages on a site. I'm noticing that there are also some updates that also need to be made in the <head> when I look at the source of the page, but I don't know how to determine where that header info is being pulled from to make that change.
Here are the two lines I'm seeing before it jumps into the HTML content:
<%# Page Language="vb" AutoEventWireup="false" Codebehind="DefaultLogin.aspx.vb" Inherits="TIMSSSSO.Web.DefaultLogin" %>
<%# Register TagPrefix="cc1" Namespace="Generic.Foundation.WebControls" Assembly="Generic.Foundation.WebControls" %>
Does any of this tell me where I should go to edit the header? Any guidance would be appreciated.

Could not load type error in application page

I have created a application page for login functionality in sharepoint by following this post.
But this giving me an error at inheriting the page. I have folder structure and .aspx file like below.
Did I done any mistake while giving the link to the .cs file in the application page?
After I deployed into my site, it is giving me error like below.
I am trying to resolve it from 2 hrs, but unable to find the solution. Can any one suggest me the way to do it please!!
Try to add
<%# Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
before
<%# Page ... %>
Add $SharePoint.Project.AssemblyFullName$ to your Inherits attribute
Instead of <%# Page Language="C#" AutoEventWireup="true" CodeBehind="YourPage.aspx.cs" Inherits="YourNamespace.YourPage" %>
Use <%# Page Language="C#" AutoEventWireup="true" CodeBehind="YourPage.aspx.cs" Inherits="YourNamespace.YourPage,$SharePoint.Project.AssemblyFullName$" %>
This could also be happened when there are another reference to that assembly which didn't exist. To show the error, simply check Ha Doan answer.

Controlling the page from reaching the top of the page

I have a registration page with many fields and DDl's when i scroll down and select the ddl value then the page going to top of the page and again i have to scroll to the control and have to select the page.How to control the page by stopping at the control even though the value is changed.
Use MaintainScrollPositionOnPostback="true" in Page directive
Something like this
<%# Page MaintainScrollPositionOnPostback="true" %>
to know more about this Go here.
Alternatively you can, put this in Web.config to make this setting global, By this
<?xml version="1.0"?>
<configuration>
<system.web>
<pages maintainScrollPositionOnPostBack="true">
</pages>
</system.web>
<configuration>

Unable To See Master Pages While Adding A Page In The Project

i am trying to add a .aspx page in the project , but while adding the .aspx page i am not getting the option to choose existing master pages.
Don't know why it is not visible; if you cannot set it, simply add it later manually to the #Page directive of your page.
It's simple:
MasterPageFile="~/Path/To/My/MasterPage.master"
E.g. on top of your ASPX page, write something like:
<%# Page
Culture="auto"
UICulture="auto"
MaintainScrollPositionOnPostback="true"
Title="The Title of your Page"
Language="C#"
MasterPageFile="~/Path/To/My/MasterPage.master"
AutoEventWireup="true"
CodeFile="MyPage.aspx.cs"
Inherits="MyPage"
%>
In addition, if you want to access the derived type of your master page, use the #MasterType directive:
<%# MasterType VirtualPath="~/Path/To/My/MasterPage.master" %>
Could be a bug with VS, try save the project with your master page then close and reopen VS.
If not as Uwe Keim mentioned above it is really easy to add the master page manually.

ASP.NET error: The page Y.ascx cannot use the user control X.ascx

I am getting the error below when trying to build the web site project in Visual Studio 2010:
The page '/WebSite/controls/C2.ascx' cannot use the user control '/WebSite/controls/C1.ascx', because it is registered in web.config and lives in the same directory as the page.
I have 2 web user controls:
controls/C1.ascx
controls/C2.ascx
The controls have been registered in web.config:
<configuration>
<system.web>
<pages>
<controls>
<add src="~/controls/C1.ascx" tagPrefix="my" tagName="C1"/>
<add src="~/controls/C2.ascx" tagPrefix="my" tagName="C2"/>
</controls>
</pages>
</system.web>
</configuration>
C1.ascx contains just a static HTML, C2.ascx is trying to include C1:
C1.ascx contains just some plain static simple HTML. C2.ascx is trying to include C1.ascx:
<%# Control Language="VB" %>
<my:C1 runat="server" />
<p>Hello from C2</p>
When trying to build the project, I am getting the error message at the top. I realise this issue can be fixed by adding another Register directive to C2.ascx...:
<%# Register Src="~/controls/C1.ascx" TagPrefix="ctl" TagName="C1" %>
...but I'm wondering if there's a cleaner solution and why am I getting the error in the first place?
Your only possible solutions are to:
Move the control out of the directory its currently sharing with outer.ascx, or
Re-register the control inside of the outer.ascx like you already mentioned
Re-write them in code as controls in a separate library
I personally think moving is the easiest, if it will work for your solutions. Second would be re-registering, even though annoying. Abstracting them out into a full code library is probably not worth the effort if this is the only reason you are doing it.
You could also put the controls into different folders. But I don't think this is much cleaner or better.
BTW: this behavior is by design, as you can read on this MSDN page (look for the yellow note almost at the end of the page).

Resources