C# - Javascript Anchor Jump To The Top?
Aug 11, 2010
I've added this code below to a MOSS 2007 web part inside OnPreRender() method.
if (!Page.ClientScript.IsClientScriptBlockRegistered("jump_to_anchor_JS"))
{
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "jump_to_anchor_JS", "window.location.hash="anchor";",true);
}
The page loads, jumps to the specific anchor, then jumps back to the top of the page. This has been tested in IE8, Firefox, Chrome, and Safari with same behavior.
View 3 Replies
Similar Messages:
Jan 26, 2010
so I'm trying to get this dropdown thing to work but it's not working... I want the page to jump to the state on the SAME page once the USER releases on the desired state within the dropdownlist box.
HTML
<asp:DropDownList ID="ddltest" runat="server">
<asp:ListItem value="AL"> Alabama </asp:ListItem>
<asp:ListItem value="AK"> Alaska </asp:ListItem>
<asp:ListItem value="AZ"> Arizona </asp:ListItem>
<asp:ListItem value="AR"> Arkansas </asp:ListItem>
<asp:ListItem value="CA"> California </asp:ListItem>
<asp:ListItem value="CO"> Colorado </asp:ListItem>
<asp:ListItem value="CT"> Connecticut </asp:ListItem>
</asp:DropDownList>
<!-- New State -->
<a name="WY" id="WY"></a>
<div>Wyoming</div>
CODE BEHIND
protected void Page_Load(object sender, EventArgs e)
{
ddltest.Attributes.Add("onchange", "window.location.href = path.options[path.selectedIndex].value;");
}
}
}
View 5 Replies
Aug 24, 2010
I have a custom user control that contains within it a repeater control. Inside this repeater I programmatically add another custom user control, which contains a text box and a custom validator. This final custom user control can be added any number of times depending on the application's logic. All of this is part of a wizard step. When the user completes the step, if any of the data added to the text boxes is incorrect the validator gets fired on post back. However, because I can have any number of these controls added to the repeater, the user has to scroll down to see any of the incorrectly completed boxes.
Due to the controls being added dynamically it is not possible to use a validation summary control - I have tried!!! Therefore, is there away I can use JavaScript to position a cursor or to jump to each incorrectly completed textbox without the user needing to scroll down the page? For example, if there are 10 textboxes, and textboxes 8 and 9 have numbers inside them inside strings, then the JavaScript should jump textbox 9.
View 1 Replies
Apr 7, 2010
I am trying to render a simple hyperlink that links to a named anchor within the page, for example:
<a href="#namedAnchor">scroll to down</a>
<a name="namedAnchor">down</a>
The problem is that when I use an ASP.NET control like asp:HyperLink or HtmlAnchor, the href="#namedAnchor" is rendered as href="controls/#namedAnchor" (where controls is the subdirectory where the user control containing the anchor is). Here is the code for the control, using two types of anchor controls, which both have the same problem:
[code]....
I am using the HtmlAnchor or HyperLink class because I want to make changes to other attributes in the code behind. I do not want to introduce a custom web control for this requirement, as the requirement I'm pursuing is not that important enough to justify abandoning the traditional ASP.NET link controls. It seems like I should be able to use the ASP.NET link controls to generate the desired link.
View 3 Replies
Apr 1, 2010
I have a link like this
<a href="#thumb" id="ctl00_allContent_btnThumb" onclick="javascript:__doPostBack('ctl00$allContent$btnThumb','')"><img alt="" src="../../images/bullet-thumb.gif"></a>
On Firefox it does what it supposed to. But it won't work on IE or Chrome.I know there are some questions on the subject here, but they haven't helped me. I'm guessing it's more specific since it envolves ASP.NET postback.
View 3 Replies
Jan 7, 2011
I am using a CSS button as
<a href="" class="btn green" title="Delete" OnServerClick="MyCodeBehindFunction">Delete </a>
Previously, I was using a button control instead of CSS button and using AJAX confirm extender before deleting. But how do I ask for this confirm action in < a href=""> now?
View 2 Replies
Mar 2, 2011
I have an ASP.NET Menu which generates many anchor tags when rendered.
My requirements were
to prevent postback if href or an anchor tag is "" or "#". to make the cursor not to show the hand First I checked the markup of one of the generated anchor tags
[code].....
When I hovered on the empty link, the cursor is showing the default one instead of hand, that means my anchor is recognized. But when I clicked the anchor, postback occurred!
Tried replacing anchor.unbind('click'); with anchor.kill('click');
Tried replacing e.preventDefault(); by appending e.stopPropogation and even return false;
Tried replacing anchor.bind('click', function(e){ with anchor.click(function(e) {
Nothing seems to work. What could be wrong with my code?
View 3 Replies
May 20, 2010
i have some page that display article (for example: www.site.com/article.aspx?articleId=3) i want to put 2 links/buttons Next article and Previous article and after user click, the page display the next or the previous article from data base. i need some code that jump to the next db row not by -1 or +1 cause maybe article was deleted and there is no such id number like 4 or 2, so to jump to the next/previous article available. any idea? if some one can help me with LINQ TO SQL it will be better (the site is allready builded with LINQTOSQL
View 3 Replies
Feb 16, 2010
I am using C# code in an event handler for a button click event in a web page that I would like to have access another web page for the user to see after certain processing is completed. What C# code do I use to execute another page in the same website?
View 1 Replies
Aug 3, 2010
I have a strange problem that I don't understand about DataPager. After changing the page set (pages 6 - 10 for example), and clicking on a page (6, 7, 8, 9 or 10), it will displa to the first set of pages counting from 1 again.
Let me explain. I have a ASP.Net page with Listview and DataPager.
<asp:ListView ... DataSourceId="EntityDataSource" DataKeyNames="id">
<LayoutTemplate>
<asp:DataPager runat="server" ID="DataPager1" PageSize="15">
<Fields>
[Code].....
All this works, but the problem is that the set of pages will not remember during postbacks. Let me explain this.
By first request of page, the pages show:
<< 1 2 3 4 5 ... >>
By clicking the ..., the next set of pages will be displayed (and also the data of page 6 will be displayed)
<< ... 6 7 8 9 10 ... >>
But when I click on page 7 to 10, the pages text will display the first set of pages 1-5.
View 1 Replies
Feb 12, 2010
well i have a home controller which has a index view, and this view has a text-field and a submit button.
When i click the submit button, i want it to jump to a controller called view...
and at the same time i want to pass the text-book value to this index method..
how would i do this..
index method signature should be..
Index(String Input)
how would i code my button function..
View 15 Replies
Sep 20, 2010
I have the folllowing DDL on a 2 tabbed Ajax tabbed container. The DDL is on the 2nd tab, the problem I am finding is that; when a user selects a value from the DDL the focus is jumpint to the 1st tab and not remaining in position as requested.
<cc1:TabPanel
runat="server"
HeaderText="Current Membership Stats"
ID="CurrentMembership">
[Code]....
View 2 Replies
Feb 13, 2011
I have an AsyncFileUpload with an image control to show a preview of the pic that is uploaded. Everything works fine, however on the postback from the asynchFileUpload the page jumps to the top of the page and then after a second or two it goes down to the proper scroll position. What can I do to avoid having the page jump to the top and then back down again on the postback ?
[Code]....
View 6 Replies
Jul 15, 2010
I've been dealing with an AJAX issue for some time now and I can't seem to find an answer anywhere. When I'm debugging and stepping thru my code it will jump into disassembly looking for a toolkit file. If I fit f5 I can continue debugging, but this happens often.
The latest one is:
Address: AjaxControlToolkit.ExtenderControlBase.ExtenderControlBase()
--- c:UsersswaltherprojectsaspNetAjaxReleases30930AjaxControlToolkitSourceAjaxControlToolkitExtenderBaseExtenderControlBase.cs
I setup the toolkit by adding a reference to AjaxControlToolkit.dll There's a line at the beginning of the markup...and everything appears to work outside of the debug issue.
[Code]....
View 2 Replies
Apr 10, 2010
I have a simple aspx page with a few TextBoxes and a submit button. Some fields are required and below the button is a ValidationSummary. The complete form is larger than screen height so one has to scroll down to reach the submit button. If I don't fill all required fields and click on submit validation fails as expected and the validation summary displays some info messages below the button. Validation happens on the client and no postback occurs.
So this all works as wished. But disturbing is that the page moves ("jumps") to top position when I click on the submit button. To see the validation summary one has to move down the page again.
I've tried to set the ShowSummary property to false (which doesn't make much sense): The validation still works (no postback) but in this case the page does not move to top position. So the problem seems to depend on rendering the validation texts.
Is there a way to prevent this page jump?
Update:
The behaviour I described above doesn't seem to be browser dependent. I've tested in five different browsers and it's everywhere the same.
View 2 Replies
Jan 26, 2010
I'm dynamically generating a PDF using ABCpdf which contains a table of contents that would link to other pages within the same PDF. The problem is that the path of the anchor tags in the HTML get changed to an absolute path to a temporary file.For example, ABCpdf would render the link's href:
<a href="#elementId">Link</a>
in the PDF as: file:///C:/Users/Aaron/AppData/Local/Temp/ABCpdf/pdfCMMYPSF.htm#elementI
View 2 Replies
Oct 31, 2010
Let's say I'm currently authenticated in an application (namely: applicationA) and I click a link that will take me to another application (namely: applicationB). Is it correct that in order to bypass authentication of applicationB, I'll just create a ticket for that application telling the web server that I'm already authenticated?
View 5 Replies
Aug 14, 2010
its simple question: if my edit cursor in at line 1 I wantto Quick jump to 5 and backforth again (to line 1)
is there a Jump Shortcut between Corresponing End/Begin tags ?
1. <blah>
2. ...
3. ...
4. ...
5. </blah>
View 5 Replies
Dec 6, 2010
I have a Report1.rdlc and it is a matrix table with drill down activiated.
I have 2 levels for row fields: Country > City
I have the value field with Navigation property set to URL as follows:=
[URL]
When Country is drilled down to become like this this URL works fine as desired:-
USA / NYC / 2000
when I move mouse over 2000, hyperlink becomes as desired
[URL]
However, if the City is not expanded, ie Country is not drilled through
ie when just USA / 10,000 (City is not expanded so all cities are included)
when I move mouse over 10,000 then URL becomes:-
[URL] where Boston is the 1st item in my City list within USA.
The problem is when user expand to Boston, ie USA/Boston/5000
they get the same [URL]
and so I will be confused in my next step.
What is the best way to deal with it so that I can tell the user has not expanded the City when USA total is clicked instead of Boston total is clicked ?
The best is when USA / 10,000 is clicked URL becomes
[URL]
View 1 Replies
Mar 9, 2011
I have a GridView control inside one Update Panel and a detail section inside another Update Panel. Initially, the detail section is hidden and when a GridView row is selected, the Detail panel becomes visible. Everything works fine except that if the GridView contains more rows and covers most of the user's screen, screen doesn't shits to the start of Detail section.I can use anchor but was just wondering if there is any other way of achieving this. Also the Detail section has multiple nested Update Panels and if I use anchor, then any of the child Update Panel's update will move the screen to the beginning of the detail Section.
View 4 Replies
Jun 2, 2010
I have gridview with div tag, i have put div tag becouse when user scroll in grid i dont want move grid header section. Its remaining ther and only move data section. Its working fine.
But my datagrid has facility to master details hiearchy of data, When user click one of button its expand details record of that particular parent item.
When user click expand button my gridview header section jump to top of page. How can i stop it
<div id="dvItems" style="height:300px; width:955px;">
View 3 Replies
Mar 15, 2011
i set anchor tag in masterpage as
<a onmouseout="mclosetime()" onmouseover="mopen('m2')" id="AnchorText5" href="#">TEst</a>
but when i run application and it render the page the anchor tag contain href address like
<a onmouseout="mclosetime()" onmouseover="mopen('m2')" id="ctl00_AnchorText5" href="../MasterPages/#">TEst</a>
i also try to set the "#" from code behind but it again show href="../masterpages/#"
View 2 Replies
Apr 4, 2011
What I am trying to achieve is to use an Eval as parameter in my anchor tag's href. The anchor is nested inside a repeater, why I cannot use the code behind to achieve this.
I have tried a few things without any luck.
<a href="http://MyWebsite/ActiveUsers?ID=InsertEvalHere"><%# Eval("Name")%></a>
The following code below is what I have tried to do:
<a href="<% "http://MyWebsite/ActiveUsers?ID=" + DataBinder.Eval(Container.DataItem("ID"))%>"><%# Eval("Name")%></a>
<a href="<% "http://MyWebsite/ActiveUsers?ID=" + Eval("ID")%>"><%# Eval("Name")%></a>
<a href="http://MyWebsite/ActiveUsers?ID=<% DataBinder.Eval(Container.DataItem("ID"))%>"><%# Eval("Name")%></a>
<a href="http://MyWebsite/ActiveUsers?ID=<%# Eval("ID")%>"><%# Eval("Name")%></a>
None of the above seemed to be right, as I keep getting this error - The tag is not well formed.
How should I handle this?
View 3 Replies
May 14, 2010
The line of controller code below works perfect in Firefox and Safari to do a response redirect to an anchor. In IE 8 the response redirect does not return to the anchor.
[Code]....
View 6 Replies
Jun 20, 2010
I am using Web Forms Routing in ASP.NET 4 and I am trying to route to a specific location on a page. On that page I have an element like <div id="3"> and I'd like to jump to this anchor from another page. For this purpose I have defined a Route in global.asax:
RouteTable.Routes.MapPageRoute("MyRoute", "Path/SubPath/{PageAnchor}",
"~/MyPage.aspx", true, new RouteValueDictionary { { "PageAnchor", null } });
The HyperLink to link to that page and the anchor "3" is defined this way in markup:
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="<%$ RouteUrl:RouteName=MyRoute,PageAnchor=#3 %>">
Link</asp:HyperLink>
The problem with the generated link is that the # character in the URL gets encoded by %23 this way: http://localhost:1234/Path/SubPath/%233 so that I reach the target page but not at the specified anchor.Is there a way to avoid this unwished URL-encoding? Or any other way to route to an anchor?
View 2 Replies