Change default postback url (.net 3.5)

Discussion in 'ASP .Net' started by musosdev, Jun 23, 2008.

  1. musosdev

    musosdev Guest

    Hi peeps

    I'm trying to change the default postback of my webpage. I'm trying to
    create a searchbox where you can just press enter and it goes to the search
    results (ala apple.com *ahem* :eek:)

    However, the page just postsback to itself when I hit enter.

    Is there any way to change the default postback behaviour for a page?! I'm
    using .net 3.5

    Thanks,


    Dan
     
    musosdev, Jun 23, 2008
    #1
    1. Advertising

  2. Button.PostBackUrl will do. You can also do it on server side with a
    Server.Transfer call. Or you can do it on client side with a javascript call
    window.navigate(url).

    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    "musosdev" <> wrote in message
    news:...
    > Hi peeps
    >
    > I'm trying to change the default postback of my webpage. I'm trying to
    > create a searchbox where you can just press enter and it goes to the
    > search
    > results (ala apple.com *ahem* :eek:)
    >
    > However, the page just postsback to itself when I hit enter.
    >
    > Is there any way to change the default postback behaviour for a page?! I'm
    > using .net 3.5
    >
    > Thanks,
    >
    >
    > Dan
     
    Eliyahu Goldin, Jun 23, 2008
    #2
    1. Advertising

  3. musosdev

    musosdev Guest

    Eliyahu,

    None of those solutions would work without either a button or a postback to
    the original page and then a forward (server.transfer, etc) - am I correct?

    I've actually managed to solve it by adding my header *outside* of the form
    tag on my master page, and creating a standard html form with an action=""
    property.

    Works a treat, although I'm sure someone will tell me why it's a bad idea ;)



    "Eliyahu Goldin" wrote:

    > Button.PostBackUrl will do. You can also do it on server side with a
    > Server.Transfer call. Or you can do it on client side with a javascript call
    > window.navigate(url).
    >
    > --
    > Eliyahu Goldin,
    > Software Developer
    > Microsoft MVP [ASP.NET]
    > http://msmvps.com/blogs/egoldin
    > http://usableasp.net
    >
    >
    > "musosdev" <> wrote in message
    > news:...
    > > Hi peeps
    > >
    > > I'm trying to change the default postback of my webpage. I'm trying to
    > > create a searchbox where you can just press enter and it goes to the
    > > search
    > > results (ala apple.com *ahem* :eek:)
    > >
    > > However, the page just postsback to itself when I hit enter.
    > >
    > > Is there any way to change the default postback behaviour for a page?! I'm
    > > using .net 3.5
    > >
    > > Thanks,
    > >
    > >
    > > Dan

    >
    >
    >
     
    musosdev, Jun 23, 2008
    #3
  4. Only Server.Transfer postbacks to the original page. Button.PostBackUrl and
    window.navigate(url) don't.

    You solution takes the header out of asp.net. Not sure what do you gain by
    this comparing with just setting PostBackUrl.

    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    "musosdev" <> wrote in message
    news:...
    > Eliyahu,
    >
    > None of those solutions would work without either a button or a postback
    > to
    > the original page and then a forward (server.transfer, etc) - am I
    > correct?
    >
    > I've actually managed to solve it by adding my header *outside* of the
    > form
    > tag on my master page, and creating a standard html form with an action=""
    > property.
    >
    > Works a treat, although I'm sure someone will tell me why it's a bad idea
    > ;)
    >
    >
    >
    > "Eliyahu Goldin" wrote:
    >
    >> Button.PostBackUrl will do. You can also do it on server side with a
    >> Server.Transfer call. Or you can do it on client side with a javascript
    >> call
    >> window.navigate(url).
    >>
    >> --
    >> Eliyahu Goldin,
    >> Software Developer
    >> Microsoft MVP [ASP.NET]
    >> http://msmvps.com/blogs/egoldin
    >> http://usableasp.net
    >>
    >>
    >> "musosdev" <> wrote in message
    >> news:...
    >> > Hi peeps
    >> >
    >> > I'm trying to change the default postback of my webpage. I'm trying to
    >> > create a searchbox where you can just press enter and it goes to the
    >> > search
    >> > results (ala apple.com *ahem* :eek:)
    >> >
    >> > However, the page just postsback to itself when I hit enter.
    >> >
    >> > Is there any way to change the default postback behaviour for a page?!
    >> > I'm
    >> > using .net 3.5
    >> >
    >> > Thanks,
    >> >
    >> >
    >> > Dan

    >>
    >>
    >>
     
    Eliyahu Goldin, Jun 23, 2008
    #4
  5. musosdev

    bruce barker Guest

    not with a webform. as you found out, setting the postbackurl, just adds
    javascript to the button. you have two options

    1) the approach you found, do not put a runat=server on the form.

    2) switch to the new MVC handler instead of using webforms. this gets around
    all the limitations of web forms and is probably better suited to someone who
    knows web technologies. if you want to go in an ajax direction, then I'd
    really recommend the switch. the main downside is that MVC is still in beta.


    -- bruce (sqlwork.com)


    "musosdev" wrote:

    > Hi peeps
    >
    > I'm trying to change the default postback of my webpage. I'm trying to
    > create a searchbox where you can just press enter and it goes to the search
    > results (ala apple.com *ahem* :eek:)
    >
    > However, the page just postsback to itself when I hit enter.
    >
    > Is there any way to change the default postback behaviour for a page?! I'm
    > using .net 3.5
    >
    > Thanks,
    >
    >
    > Dan
     
    bruce barker, Jun 23, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon paugh
    Replies:
    1
    Views:
    950
  2. Harold
    Replies:
    4
    Views:
    3,874
    Harold
    Dec 8, 2004
  3. cjbland
    Replies:
    0
    Views:
    1,661
    cjbland
    Feb 24, 2006
  4. guenther schoebel
    Replies:
    2
    Views:
    6,550
    Eric Cartman
    Oct 10, 2003
  5. Just D.
    Replies:
    0
    Views:
    554
    Just D.
    Aug 11, 2004
Loading...

Share This Page