Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 16th, 2003, 09:30 AM
Authorized User
 
Join Date: Oct 2003
Posts: 89
Thanks: 0
Thanked 0 Times in 0 Posts
Default ANCHOR

I have a page where the user enters his details and then clicks the save button. If there are errors in the user's details a repeater appears at the bottom of the page with the list of errors. I want the scrollbar to be positioned where the repeater is as otherwise the user might not notice the repeater.
Where must i put the line Response.Redirect("paydetails.aspx?#anch")?
I have tried putting it in a few places in my code but i was not successful.It takes me back to the default.aspx.

aspx.vb
Private Sub SaveOrderData()

        'update fields
        If Order Is Nothing Then
            Response.Write("No Order")
            Exit Sub
        Else
  Order.PayOrderType = CType(drpCPay.SelectedValue, YBayTools.PayOrder.PayOrderTypeEnum)
Order.CardType = drpCCType.SelectedItem.Value

   End If

        Order.ValidateValues = False
        If Not Order.Validate() Then

            Repeater2.DataSource = Order.ErrorDescription()

            Repeater2.DataBind()
            Exit Sub
        Else

            Repeater2.Visible = False

        End If

        If Not Order.SaveOrder Then
            Session("sysError") = Order.strSysError
            Response.Redirect("sysError.aspx")

        Else
            PopulateFields()
        End If
    End Sub

aspx:
<a name="anch"></a>
<TABLE id="Table2" style="Z-INDEX: 101; LEFT: 336px; POSITION: absolute; TOP: 500px" cellSpacing="1" cellPadding="1" width="300" bgColor="#ffff33" border="1">
<asp:repeater id="Repeater2" runat="server">
<HeaderTemplate>
<tr>
<td align="center" dir="rtl" bgcolor="#ff3333"> ðîöàå
ùâéàåú áä÷ìãú ðúåðéí.
<br>
ìäìï øùéîú äùâéàåú:
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<TR>
<TD align="right" dir="rtl"><%#Container.DataItem%><br>

</TD>
</TR>
</ItemTemplate>
</asp:repeater></TABLE>
    </body>





 
Old December 16th, 2003, 09:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

You don't need the '?' in your redirect.

Response.Redirect("paydetails.aspx#anch")

Try that and place where ever you detect the error.

 
Old December 16th, 2003, 11:27 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

When your page posts back, it's always going to post back to the url that is in the browser. Unfortunately, you can't (easily) modify the URL that the page is posting to. Furthermore, in your scenario that wouldn't be useful anyway as you aren't determining the validation of the form until you are already processing the postback.

Response redirect is probably not what you want either. If you redirect, you are going to loose the modifications the user has made within the form.

Some browsers implement the "scrollIntoView" method. You could write out a little javascript when you detect errors and show the repeater. The javascript should look something like this:

document.getElementById['controlID'].scrollIntoView();

You need to replace controlID with the complete unique control ID from .net. Get it with Repeater2.ClientID in your ASP code. Use RegisterStartUpScript() in .net to get the script chunk on the page (More info on RegisterStartUpScript()). You must include the start and end script tags when you call that method.

Take a look on google for links to details on scrollIntoView().


PS. Using "Exit Sub" is considered bad form by many programmers. It can make applications extremely hard to troubleshoot

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old December 17th, 2003, 03:43 AM
Authorized User
 
Join Date: Oct 2003
Posts: 89
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Thanks guys for the help. I did as Peter suggested and it works but i had to add an input type hidden. If i referred to document.getElementById("Repeater2").scrollIntoVie w(); then it gave me that the object is empty. Is that perhaps because it appears only if there is an error?
Referring to the hidden field works:
document.getElementById("hidden").scrollIntoView() ;






Similar Threads
Thread Thread Starter Forum Replies Last Post
Anchor Tag kapilmirchi ASP.NET 1.0 and 1.1 Basics 2 November 18th, 2008 05:57 AM
PDF Anchor Problem kwilliams Other Programming Languages 0 January 10th, 2007 11:41 AM
onClick and go to anchor #something Parabolart Javascript 7 November 28th, 2006 06:45 AM
anchor and get variables. SignalFade Beginning PHP 4 January 19th, 2006 08:56 PM
Help with paginating and anchor link. major dynamic123 Pro PHP 6 September 11th, 2003 01:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.