Simple LinkButton

  • Thread starter Thread starter RN1
  • Start date Start date
R

RN1

An ASPX page, named LinkButton.aspx, has a single LinkButton & nothing
else. The code is very simple:

<form runat="server">
<asp:LinkButton ID="lnk" PostBackUrl="Page1.aspx" Text="CLICK"
runat="server"/>
</form>

When I run the above code in my local; (Intranet) IIS server, then
when the LinkButton is clicked, the user is taken to Page1.aspx but
when I uploaded the above ASPX file to a remote server & ran the page,
clicking the LinkButton doesn't take the user to Page1.aspx. Rather,
the user is brought back to LinkButton.aspx.

Why so? If I am not mistaken, PostBackUrl means posting a page to
itself (unlike the NavigateUrl property of the HyperLink control which
takes the user to a different page); so why is the LinkButton behaving
differently when the ASPX page is run in my local server & when the
same ASPX page is run in a remote server?

Also when I right-click the link & then click "Properties" in my local
server, the URL is

javascript:WebForm_DoPostBackWithOptions(new
%20WebForm_PostBackOptions("lnk",%20"",%20false,%20"",%20"Page1.aspx",
%20false,%20true))

but the URL of the link in the remote server turns out to be

javascript:__doPostBack('lnk','')

Why?

Thanks,

Ron
 
An ASPX page, namedLinkButton.aspx, has a singleLinkButton& nothing
else. The code is verysimple:

<form runat="server">
<asp:LinkButtonID="lnk" PostBackUrl="Page1.aspx" Text="CLICK"
runat="server"/>
</form>

When I run the above code in my local; (Intranet) IIS server, then
when theLinkButtonis clicked, the user is taken to Page1.aspx but
when I uploaded the above ASPX file to a remote server & ran the page,
clicking theLinkButtondoesn't take the user to Page1.aspx. Rather,
the user is brought back toLinkButton.aspx.

Why so? If I am not mistaken, PostBackUrl means posting a page to
itself (unlike the NavigateUrl property of the HyperLink control which
takes the user to a different page); so why is theLinkButtonbehaving
differently when the ASPX page is run in my local server & when the
same ASPX page is run in a remote server?

Also when I right-click the link & then click "Properties" in my local
server, the URL is

javascript:WebForm_DoPostBackWithOptions(new
%20WebForm_PostBackOptions("lnk",%20"",%20false,%20"",%20"Page1.aspx",
%20false,%20true))

but the URL of the link in the remote server turns out to be

javascript:__doPostBack('lnk','')

Why?

Thanks,

Ron

Can someone please clear my doubts?

Thanks,

Ron
 
Can someone please clear my doubts?

I dislike anything in .net that uses javascript postback links. They're not
accessible and tend to hide the logic.

Now, maybe that's unfair, but when I need to make public-facing websites, I
tend to avoid them.

So, anyhow, it appears that the source code on your local machine just isn't
the same as what's on your server. Are you SURE the files are the same?

-Darrel
 
I dislike anything in .net that uses javascript postback links. They're not
accessible and tend to hide the logic.

Now, maybe that's unfair, but when I need to make public-facing websites, I
tend to avoid them.

So, anyhow, it appears that the source code on your local machine just isn't
the same as what's on your server. Are you SURE the files are the same?

-Darrel

Yes Darrel I am more than 100% sure that the files on my Intranet &
remote server are the same. It was I only who created & uploaded the
ASPX file.
 
Back
Top