[CLOSED] [1.0] Button's target link

  1. #1

    [CLOSED] [1.0] Button's target link

    Hi,
    I have a menu in a toolbar such as defined below:

        <ext:Panel ID="PanelMaster" runat="server" Title="Center" Header="False" BodyBorder="false" >
           <Items>
               <ext:Toolbar runat="server" ID="MENU">
                   <Items>
                        <ext:Button runat="server" ID="BOTTONE_DIRETTO" Text="BOTTONE">
                            <Listeners>
                                <Click Handler="document.location.href='Link.aspx';" />
                            </Listeners>
                        </ext:Button>                                      
                       
                       <ext:Button runat="server" ID="BOTTONE_1" Text="MENU">
                           <Menu>
                               <ext:Menu runat="server" ID="SUB_1" Width="200">
                                   <Items>
                                       <ext:MenuItem runat="server" ID="Menu_1" Text="VOCE_MENU_1" Icon="Key"  Href="Link1.aspx" HrefTarget="_blank">
                                       </ext:MenuItem>
                                       <ext:MenuSeparator />
                                       <ext:MenuItem runat="server" ID="Menu_2" Text="VOCE_MENU_2" Icon="House"  Href="link2.aspx" Hreftarget="_blank">
                                       </ext:MenuItem>                                                
                                       <ext:MenuSeparator />
                                       <ext:MenuItem runat="server" ID="MenuItem2" Text="VOCE_MENU_3" Icon="Folder"  Href="link3.aspx" HrefTarget="_blank">
                                       </ext:MenuItem>
                                   </Items>
                               </ext:Menu>
                            </Menu>
                        </ext:Button>
                   </Items>
               </ext:Toolbar>
            </Items>
        </ext:Panel>
    I would like that "BOTTONE_DIRETTO" will open link on new page (target=_blank); how can I do this ? I try adding "documento.location.target='_blank';" but it does not work!!!
    I do not want to use a window.open javascript command.

    In submenu there is HrefTarget property...

    Many Thanks
    Last edited by geoffrey.mcgill; Nov 22, 2010 at 2:58 PM. Reason: [CLOSED]
  2. #2
    Hi,

    There is <a> html element in MenuItem. Therefore the HregTarget property exists there.

    And there is no <a> element in Button.

    I have looked up on the internet, have many links with the same question but no solution without window.open().

    What about <ext:HyperLink>?
  3. #3
    Hi Daniil,
    <ext:HyperLink> could be ok but it does not look like a button... maybe there are some properties to set to make it like a button ??!! :o
  4. #4
    Hi,

    Why you don't want to use window open? Do you fear that the popup window may be blocked?
    What about to use Ext.Net window with iframe?
  5. #5
    Hi,

    What about the following thing?:) I use XTemplate (based on Button's template) and BoxComponent.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    
        <style type="text/css">
            .myClass a {
                color: black;
            }
        </style>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:XTemplate ID="XTemplate1" runat="server">
            <Html>
            <table cellspacing="0" class="x-btn {5}">
                <tbody class="{4}">
                        <tr><td class="x-btn-tl"><i>&#160;</i></td><td class="x-btn-tc"></td><td class="x-btn-tr"><i>&#160;</i></td></tr>
                        <tr>
                            <td class="x-btn-ml"><i>&#160;</i></td>
                            <td class="x-btn-mc">
                                <a id="{0}" href="{1}" target="{2}">{3}</a>
                            </td>
                            <td class="x-btn-mr"><i>&#160;</i></td></tr>
                        <tr><td class="x-btn-bl"><i>&#160;</i></td><td class="x-btn-bc"></td><td class="x-btn-br"><i>&#160;</i></td></tr>
                </tbody>
            </table>
            </Html>
        </ext:XTemplate>
        <ext:BoxComponent runat="server" Tpl="={XTemplate1}">
            <Listeners>
                <Render Handler="this.tpl.append(this.container, ['someId', 'http://google.com', '_blank', 'Hello World!', 'x-btn-small x-btn-icon-small-left', 'myClass'], true);"/>
            </Listeners>
        </ext:BoxComponent>
        </form>
    </body>
    </html>
  6. #6
    Hi again,

    Here is another solution.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    
        <script type="text/javascript">
            var myGetTemplateArgs = function() {
                return [this.href, 'x-btn-' + this.scale + ' x-btn-icon-' + this.scale + '-' + this.iconAlign, this.target, this.cls, this.id];
            }
    
            var myOnClick = function(e) {
                //if (e) {                  
                //    e.preventDefault();
                //}
                if (e.button !== 0) {
                    return;
                }
                if (!this.disabled) {
                    this.doToggle();
                    if (this.menu && !this.hasVisibleMenu() && !this.ignoreNextClick) {
                        this.showMenu();
                    }
                    this.fireEvent('click', this, e);
                    if (this.handler) {
                        this.handler.call(this.scope || this, this, e);
                    }
                }
            }
        </script>
    
        <style type="text/css">
            .myClass a {
                color: black;
                text-decoration: none;
            }
        </style>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:XTemplate ID="XTemplate1" runat="server">
            <Html>
            <table id="{4}" cellspacing="0" class="x-btn {3}">
                <tbody class="{1}">
                        <tr><td class="x-btn-tl"><i>&#160;</i></td><td class="x-btn-tc"></td><td class="x-btn-tr"><i>&#160;</i></td></tr>
                        <tr>
                            <td class="x-btn-ml"><i>&#160;</i></td>
                            <td class="x-btn-mc">
                                <a href="{0}" target="{2}"></a>
                            </td>
                            <td class="x-btn-mr"><i>&#160;</i></td></tr>
                        <tr><td class="x-btn-bl"><i>&#160;</i></td><td class="x-btn-bc"></td><td class="x-btn-br"><i>&#160;</i></td></tr>
                </tbody>
            </table>
            </Html>
        </ext:XTemplate>
        <ext:Button 
            runat="server" 
            Template="={XTemplate1}" 
            ButtonSelector="a:first-child"
            Text="Click me!" 
            Href="http://google.com" 
            Target="_blank" 
            GetTemplateArgs="={myGetTemplateArgs}"
            Cls="myClass" 
            XOnClick="={myOnClick}">
        </ext:Button>
        </form>
    </body>
    </html>
  7. #7
    Quote Originally Posted by Vladimir View Post
    Hi,

    Why you don't want to use window open? Do you fear that the popup window may be blocked?
    What about to use Ext.Net window with iframe?
    Hi Vlad,
    exactly!!! I am afraid of window popup would be blocked!!!

    Ext.net window with iframe ? Please, can you provide me an example ??

    I saw Daniil's solutions but they are not so elegant; I prefer not to use XTemplate, sorry!!!

    Many thanks
  8. #8
    Hi,

    Please look at the example.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:Button runat="server" Text="Click me">
            <Listeners>
                <Click Handler="Window1.load('http://google.com'); Window1.show();"/>
            </Listeners>
        </ext:Button>
        <ext:Window 
            ID="Window1" 
            runat="server" 
            Width="500" 
            Height="500" 
            Hidden="true" />
        </form>
    </body>
    </html>
    See also
    http://dev.sencha.com/deploy/dev/doc...el&member=load
  9. #9
    Hi,
    many thanks for your suggestions!!!
    At the end I have used an <ext:button> that compiles a <form> where I set target's property to "_blank"

Similar Threads

  1. How to add link button in gripanel cells
    By Binai in forum 1.x Help
    Replies: 2
    Last Post: May 30, 2012, 4:43 AM
  2. [CLOSED] HTMLEditor link with new window (target=_blank)
    By jchau in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 18, 2012, 9:53 AM
  3. [CLOSED] Change EventEditWindow: Remove save button and edit link
    By ddslogistics in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Feb 28, 2011, 3:16 PM
  4. [CLOSED] AllowBlank Message Target
    By albayrak in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Feb 09, 2011, 2:26 PM
  5. [CLOSED] Custom Animate Target
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 30, 2009, 7:53 AM

Tags for this Thread

Posting Permissions