Change default postback url (.net 3.5)

M

musosdev

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
 
M

musosdev

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 said:
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 said:
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
 
E

Eliyahu Goldin

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 said:
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 said:
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 said:
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
 
B

bruce barker

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)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top