Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...What you have done for people like me is immeasurably helpful."

Geography

Where in the world do Tek-Tips members come from?
dpdg (Programmer)
9 May 12 23:59
I'm using .net framework 4.0. I have an asp.net site that uses a menu to call a JS function which fires an update panel to load the content area with text -- it works fine. But now the Context.RewritePath method doesn't fire in the Global.asax file.

If I put the page name after the domain name the page_load even doesn't fire and it goes to "The resource cannot be found." error page.

1) Is there any way that I can get the Rewrite method to run when I click on a menu item?

2) Also is there a way to load the default.aspx page and run the ajax method when I enter the URL and press enter? Example:

http://mywebsite.com/my-post-page

It worked fine before I implemented the AJAX functionality, but after that it won't post back. I'd like it load the Default.aspx page the first time but after that I would just run the ajax functionality and change the url in the address bar.

I guess I'm wanting my cake and eat it too.

I was really getting tired of my WP blog (written in PHP) taking 15 to 25 seconds to load a page and doing everything I could to get it to run faster. So I decided to write my own blog using AJAX and asp.net.

The post loads instantly with AJAX but I have a lot of bookmarks out there (2 years worth) saved to people's bookmarks bar and if they run click it to go back to my site they'll get a "The resource cannot be found" error.

Is there anyway to get my asp.net site to run the way I want it to?

Here's the code on my default.aspx page:

CODE

   <asp:ScriptManager ID="ScriptManager1" runat="server" />
  <div style="display:none">
    <asp:Button ID="Button1" Text="Submit" OnClick="Button1_Click" runat="server"  />
    <asp:HiddenField ID="HiddenField1" runat="server"  />
  </div>
  <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
    <Triggers>
      <asp:AsyncPostBackTrigger ControlID="Button1" />
    </Triggers>
    <ContentTemplate>
      <asp:Label ID="PostTitle" runat="server" Font-Size="Large"></asp:Label>
      <asp:LinkButton CssClass="showcomments" ID="lnkShowComments" runat="server">Show Comments</asp:LinkButton>
      <br />
      <asp:Label ID="Content" runat="server" Width="95%"
      Font-Names="verdana" Font-Size="8pt" Font-Bold="false" ></asp:Label>
    </ContentTemplate>
  </asp:UpdatePanel>

And here's the javascript function the fires it:

CODE

    function GetContent(t) {
        document.getElementById("HiddenField1").value = t;
        var button = document.getElementById("Button1");
        button.click();
    }

Thanks!

Doug  
Qik3Coder (Programmer)
10 May 12 15:16

Doug,
You could come at this another way.
Look at trapping a 404 in your global.asax (Application_Error). Then just redirect them to the default page.

Lodlaiden

You've got questions and source code. We want both!
Oh? That? That's not an important password. - IT Security Admin (pw on whiteboard)

dpdg (Programmer)
10 May 12 23:11

Thanks! That worked out perfect!

dpdg (Programmer)
10 May 12 23:12

Now I'd like the rewrite method to run when I click a link that runs the javascript that triggers the updatepanel, so that the URL will change to the correct page name. But I would suppose that could only run on a postback... Is there any way I could do that?

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close