localized back button

  • Thread starter Thread starter wwildenborg
  • Start date Start date
W

wwildenborg

I got it to work, but somehow it doesn't seem like the proper solution.
I can't switch anymore to design view for instance.

<input id="cmd_back" class=button type="button" value="<asp:Localize
ID='Localize13' Text='<%$ Resources:Catalogue, Back %>'
runat='server'></asp:Localize>" onclick="history.back(1);" />

I suppose it would be easier to use a <asp:button>, but I can't get
that one to not postback. As you can tell I am reasonably new to
asp.net 2. How do I manage to make an <asp:button> that does not post
back?
 
You can use a <asp:Button> with its UseSybmitBehaviour property set to
false. Also, ypo can use its OnClientClick property to link to
javascript code.

-Dhanvanth
 
Alternatively,
<asp:Localize ID='Localize13' Text='<%$ Resources:Catalogue, Back %>'
runat='server'></asp:Localize>
<input type="button" value="<%= Localize13.Text %>
 
I tried that, but doesn't work.
<asp:Button ID="Button1" CssClass=button runat="server" Text="<%$
Resources:Catalogue, Back %>" UseSubmitBehavior="false"
OnClientClick="history.back(1);" />

This is the HTML it generates:
<input type="button" name="ctl00$MainContent$Button1" value="Back"
onclick="history.back(1);__doPostBack('ctl00$MainContent$Button1','')"
id="ctl00_MainContent_Button1" class="button" />

Now, if I could only get rid of
__doPostBack('ctl00$MainContent$Button1','').
 
Thanks ... it works and I can switch to design-view again. It does
leave me to wonder: is there no way to prevent an ASP:button to do a
postback?
 
You can intercept the postback via javascript by adding a client side
onClick. Otherwise, no, that's what it does. If you don't need that
behaviour, use a server side HtmlButton:

<button id="b" runat="server" ... />

Karl
 
Back
Top