2013-07-26 43 views
0

有人可以請解釋爲什麼按鈕的圖標不會顯示在按鈕1和按鈕3? Button1是一個asp:按鈕,Button2是一種Button,Button3是HTML按鈕。 如何讓圖標顯示在所有3個按鈕上?JQuery UI按鈕圖標不顯示在不同的按鈕類型

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" 
    CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %> 

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> 
<script type="text/javascript"> 
    $(document).ready(function() { 
     $("[id$=Button1]").click(function() { 
      alert("Welcome button1 !"); 
     }); 

     $("[id$=Button2]").click(function() { 
      alert("Welcome button2 !"); 
     }); 

     $("[id$=Button3]").click(function() { 
      alert("Welcome button3 !"); 
     }); 

     $("[id$=Button1]").button({ 
      icons: 
       { 
        primary: "ui-icon-search" 
       } 
     }); 

     $("[id$=Button2]").button({ 
      icons: 
       { 
        primary: "ui-icon-search" 
       } 
     }); 

     $("[id$=Button3]").button({ 
      icons: 
       { 
        primary: "ui-icon-search" 
       } 
     }); 
    }); 
</script> 
</asp:Content> 
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> 
    <asp:Button ID="Button1" runat="server" Text="Button1" /> 
    <button id="Button2">Button2</button> 
    <input id="Button3" type="button" value="Button3"></input> 
</asp:Content> 

回答

0

我不這麼認爲,所以你可以得到像這樣的jQuery中的ASP按鈕id。當asp.net id在html中呈現時,它變成這樣的id =「ctl00_Button1」。您可以改爲應用CssClass =「Button1」。等其他asp按鈕。

+0

我也這麼認爲,但它肯定是因爲JQueryUI風格被應用到所有按鈕,並且警報在所有3個按鈕上工作。 或者我只能使用那個工程即ie。