• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1160
  • Last Modified:

how do I get rid of the "javascript:__doPostBack ... " on link buttons?

I have some link buttons and hyperlinks that have custom JavaScript popups designed to simply open  a pop-up preview window:
                                                      <asp:Button ID="btnPreviewTemplate" runat="server" Text="Preview" CssClass="normalButton" UseSubmitBehavior="False" CausesValidation="False" />
                                                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" EnableTheming="True" EnableViewState="False">Preview</asp:LinkButton>
 
I set the OnClientClick equal to a url in the code behind (since the filename changes):
"javascript:window.open('" + url + "em/" + Me.ddNewsLetters.SelectedValue.ToString + "_Final.htm" + "','Preview" + CommonLogic.GetRandomNumber(1, 100000).ToString() + "','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=630,height=800,left=0,top=0');"

When I view the source, a javascript:__doPostBack is appended to the end of the string.

 <input type="button" name="btnPreviewTemplate" value="Preview" onclick="javascript:window.open('http://www.mywebsite.com/em/34_Final.htm','Preview32914','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=630,height=800,left=0,top=0');__doPostBack('btnPreviewTemplate','')" language="javascript" id="btnPreviewTemplate" class="normalButton" style="color:Navy;background-color:#D2D2D2;border-color:#404040;border-width:1px;border-style:Solid;" />
                                                        <a onclick="javascript:window.open('http://www.mywebsite.com/em/34_Final.htm','Preview32914','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=630,height=800,left=0,top=0');" id="LinkButton1" href="javascript:__doPostBack('LinkButton1','')">Preview</a>
                                   
I'll probably end up using a Literal, but think there is something missing here.  I want to completely avoid a postback in both cases, but don't see a way to prevent them.  
0
bd9000
Asked:
bd9000
1 Solution
 
appariCommented:
try
"javascript:window.open('" + url + "em/" + Me.ddNewsLetters.SelectedValue.ToString + "_Final.htm" + "','Preview" + CommonLogic.GetRandomNumber(1, 100000).ToString() + "','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=630,height=800,left=0,top=0');return false;"
0
 
bd9000Author Commented:
Works like a charm! Thanks!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now