asp.net web matrix

K

Kenneth Windish

Hi,

I wrote a simple web application using web matrix. When I run it on my local
computer all works fine, but when I run it on hosting site all hyperlinks
are not working and just postback to the original page. I have rechecked the
links and they are set right, & work on local computer, but not on hosted
site. I have noticed that when you mouse over the link on local host the
adress shows like javascript:WebForm_dopostbackwithoptions(new
webform_postbackoptions("linkbutton1","",false,"","support.aspx") but on the
hosting site the adress shows javascript:
_dopostback('linkbutton1',"). Any ideas??


TIA
Ken
 
K

Kenneth Windish

Hi,

I have found that the reason this is happing is that the other forms are not
being found. the following is the code for a link:
<asp:linkbutton id="linkbutton1" runat="server"
postbackurl="support.aspx">Support</asp:linkbutton>

is the syntax for the bostback url correct?

all web forms on the server are in wwwroot directory as is the main index
page.

Are web forms in the right directory?

TIA

Ken
 
J

Juan T. Llibre

re:
is the syntax for the postback url correct?

You can't get there from here.

One of the biggest differences between ASP and ASP.NET
is that in ASP.NET, a Web Form must post back to itself instead
of posting to a different page.

Historically, developers posted to a different page by setting the form's
action attribute. Posting to a separate page used to be a good idea
because it made for a cleaner separation of code from HTML.

Now, because ASP.NET handles events in the same Web Form in
which they're raised, the form must post back to the same page.

Even if you set the action attribute of the form to a different page,
the Web server finds the runat="server" attribute setting and
overrides your action value.




Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
 
J

Juan T. Llibre

I should have added that it's not possible in ASP.NET 1.1,
which you are using.

ASP.NET 2.0 introduces the ability to post to a different page,
and you *can* use the PostBackUrl="~/Page2.aspx"
attribute in ASP.NET 2.0.

Read Brock Allen's excellent article on the subject :

http://staff.develop.com/ballen/blog/PermaLink.aspx?guid=483742fd-01a2-4975-b76c-d3b8b4f29eaf



Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
 
K

Kenneth Windish

Hi,

Thanks for responding.

You mean that I can write web pages that work fine when run from my local
computer with the web matrix server, but they won't work when placed on a
hosting server?
Seems like a big waste.

Ken
 
J

Juan T. Llibre

It's no waste. It's just the way it is.
You can't do it with ASP.NET 1.1. Period.

You *can* do it with ASP.NET 2.0.

Look into using Response.Redirect, if you want to use 1.1.



Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
 
K

Kenneth Windish

Hi,

What I am saying is why even have a link button if it can't link to anything
in the real world only in a test environment on your local computer?
Thats what seems like a waste.

Ken
 
J

Juan T. Llibre

Kenneth,

we have a semantics issue here in that the
"postbackurl" attribute is badly named.

You *can* use the linkbutton to *link* to a different page.
You cannot use it to *post* the page it's on to another page.

"postbackurl" should be named something else to prevent confusion.

If the attribute's name was "linkurl" like this example :
<asp:linkbutton id="linkbutton1" runat="server"
linkurl="support.aspx">Support</asp:linkbutton>

it wouldn't confuse anyone.

I hope that makes the issue clearer to you ( and others ).




Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
 
K

Kenneth Windish

Hi,

Thanks for your info. Not really sure what the button is linking, or how
that link works, but I now realize that what I should have been using was a
hyperlink instead of a linkbutton.

Thanks for your input.

Ken
 
J

Juan T. Llibre

Hi, Kenneth.

I found your input so interesting that I submitted a suggestion
at the Microsoft Product Feedback Center, asking that they
rename "postbackurl" to "navigateurl", like the Hyperlink.

You may want to support the suggestion by voting for it.

http://lab.msdn.microsoft.com/produ...edbackid=50f9f8e6-38bb-41d0-8dd5-32df70cfd903

Thanks!



Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
 
J

Jon Paal

What's appears to be wrong is mixing ASP.net 2.0 with ASP.net 1.1.

Webmatrix is a development tool that helps you write code, but is designed to develop code for version 1.1 You can type in anything
though including code that is supposed to be used for version 2.0 only.

You are using the linkbutton feature called "Postbackurl", which a new 2.0 feature. You may have ASP.net 2.0 installed on your
machine but the webhost apparently not have it installed on their machine so that feature will not work.

verify your webhost has 2.0 installed and working
 
J

Jon Paal

It would be nice if it supported both, since a button can be used inside a form as well as outside a form. this might be a bit
redundant but should help to be a bit more relevant to the relative usage.
 
K

Kenneth Windish

Hi,

Thanks for the info. I will check webhost. Problem was solved by changing
linkbuttons w/hyperlinks. Not being that fimilar with the whole web thing I
confused the two.

Ken
 

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

Top