localized back button

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?
 
D

dhanvanth

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
 
K

Kerem OZMAN

Alternatively,
<asp:Localize ID='Localize13' Text='<%$ Resources:Catalogue, Back %>'
runat='server'></asp:Localize>
<input type="button" value="<%= Localize13.Text %>
 
W

Willem

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','').
 
W

Willem

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?
 
K

Karl Seguin [MVP]

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
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top