2013-07-26 45 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。