This is a migrated thread and some comments may be shown as answers.

ToolBar & Scripts problem

2 Answers 81 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Jesús
Top achievements
Rank 1
Jesús asked on 05 Dec 2008, 01:46 PM
I'm migrating from Q2 2007 version to Q3 2008.

I have the following code:

<asp:Panel ID="toolBarPanel" runat="server"
    <radTlb:RadToolbar ID="toolBar" runat="server" UseFadeEffect="True" Skin="Mac" ButtonHeight="24px" 
        ButtonWidth="24px" AutoPostBack="true" CatalogIconImageUrl="" SkinsPath="~/RadControls/Toolbar/Skins" 
        ImagesDir="~/Imagenes/" OnOnClick="toolBar_OnClick" OnPreRender="toolBar_PreRender" 
        ValidationGroup="GV1" > 
        <Items> 
            <radTlb:RadToolbarButton ID="button1" ButtonImage="image1.png" CommandName="CMD1" 
                runat="server" ButtonText="CMD1" Hidden="False" CausesValidation="false" /> 
            <radTlb:RadToolbarButton ID="button2" ButtonImage="image2.png" CommandName="CMD2" 
                runat="server" ButtonText="CMD2" Hidden="False" CausesValidation="false" /> 
        </Items> 
    </radTlb:RadToolbar> 
 
    <script type="text/javascript"
<!-- 
<%= toolBar.ClientID %>.attachEvent("OnClientClick","click_handler"); 
function click_handler(sender, e) 
    if (sender.CommandName=='DELETE') { 
        return confirm('<%= MissatgeDinamic("Del1") %>'); 
    } 
--> 
    </script> 
</asp:Panel> 

and now I have translated it to the following one.

<asp:Panel ID="toolBarPanel" runat="server"
    <telerik:RadToolBar ID="toolBar" runat="server" UseFadeEffect="True" Skin="Gray" ButtonHeight="24px" 
        ButtonWidth="24px" AutoPostBack="true" OnButtonClick="toolBar_OnButtonClick" OnPreRender="toolBar_PreRender" 
        ValidationGroup="GV1" > 
        <Items> 
            <telerik:RadToolbarButton ID="button1" ImageUrl="~/Imagenes/image1.png" CommandName="CM1" 
                runat="server" ButtonText="CMD1" Hidden="False" CausesValidation="false" /> 
            <telerik:RadToolbarButton ID="button2" ImageUrl="~/Imagenes/image2.png" CommandName="CM2" 
                runat="server" ButtonText="CMD2" Hidden="False" CausesValidation="false" /> 
        </Items> 
    </telerik:RadToolBar> 
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"
      <script type="text/javascript"
        $find("<%= toolBar.ClientID %>").attachEvent("OnClientClick","click_handler"); 
        function click_handler(sender, e) 
        { 
            if (sender.CommandName=='DELETE') { 
                return confirm('<%= MissatgeDinamic("Del1") %>'); 
            } 
        } 
      </script> 
    </telerik:RadCodeBlock> 
</asp:Panel> 

When I execute this appears a Visual Studio 2008 pop-up window with the message (I translate from Spanish) Microsoft JScript error at execution time: 'null' is null or not is an object, and the generated code I can see is:

<div id="toolBar" class="RadToolBar RadToolBar_Horizontal RadToolBar_Gray RadToolBar_Gray_Horizontal " UseFadeEffect="True" ButtonHeight="24px" ButtonWidth="24px" style="z-index:9000;"
<div class="rtbOuter"
    <div class="rtbMiddle"
        <div class="rtbInner"
            <ul class="rtbUL"
                <li class="rtbItem rtbBtn"><class="rtbWrap" ID="button1" href="#"><span class="rtbOut"><span class="rtbMid"><span class="rtbIn"><img alt="" src="Imagenes/image1.png" class="rtbIcon" /></span></span></span></a></li><li class="rtbItem rtbBtn"><class="rtbWrap" ID="button2" href="#"><span class="rtbOut"><span class="rtbMid"><span class="rtbIn"><img alt="" src="Imagenes/image2.png" class="rtbIcon" /></span></span></span></a></li
            </ul> 
        </div> 
    </div> 
</div><input id="toolBar_ClientState" name="toolBar_ClientState" type="hidden" /> 
</div> 
 
    <script type="text/javascript"
$find("toolBar").attachEvent("OnClientClick","click_handler"); 
function click_handler(sender, e) 
    if (sender.CommandName=='DELETE') { 
        return confirm('¿Seguro de borrar este elemento?'); 
    } 
    < 

What is happening here? Any solution for this?




2 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 08 Dec 2008, 12:27 PM
Hi there,

You're actually migrating from RadToolBar for ASP.NET to RadToolBar for ASP.NET AJAX, they are quite different, your code should be changed like this:

<asp:Panel ID="toolBarPanel" runat="server">
<telerik:RadToolBar ID="toolBar" runat="server"
AutoPostBack="true" OnButtonClick="toolBar_OnButtonClick" OnPreRender="toolBar_PreRender"
ValidationGroup="GV1" OnClientButtonClicked="click_handler">
<Items>
<telerik:RadToolbarButton ID="button1" ImageUrl="~/Imagenes/image1.png" CommandName="CM1"
runat="server" Text="CMD1" Hidden="False" CausesValidation="false" />
<telerik:RadToolbarButton ID="button2" ImageUrl="~/Imagenes/image2.png" CommandName="CM2"
runat="server" Text="CMD2" Hidden="False" CausesValidation="false" />
</Items>
</telerik:RadToolBar>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function click_handler(sender, e)
{
   if (e.get_item().get_commandName()=='DELETE') {
     return confirm('test');
   }
}
</script>
</telerik:RadCodeBlock>
</asp:Panel>

Best wishes,
Yana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jesús
Top achievements
Rank 1
answered on 09 Dec 2008, 03:17 PM
Ok, it works!

Thanks.
Tags
ToolBar
Asked by
Jesús
Top achievements
Rank 1
Answers by
Yana
Telerik team
Jesús
Top achievements
Rank 1
Share this question
or