简体   繁体   English

需要有关按钮的CSS的建议

[英]Need advice for CSS for the button

I have an asp.net page. 我有一个asp.net页面。 There is sidebar in which there are several buttons. 边栏有几个按钮。 There is another button "Edit". 还有另一个按钮“编辑”。 Please look at my image: 请看我的图片: 图片

My question: I don't want the button "Edit" displayed unless a button in the sidebar is clicked. 我的问题:我不希望显示“编辑”按钮,除非单击侧边栏中的按钮。 Rightnow it is defaulted show up. 现在,它是默认显示。 My goal is "Edit" doesn't show uncless say click "Problems1" then "Edit" will show up underneath the gridview. 我的目标是不显示“编辑”,除非单击“问题1”,然后在网格视图下方将显示“编辑”。 My code: 我的代码:

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="WebTest._Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script  type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script  type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<link href="Styles/Site.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<div id="wrap">
 <div id="sidebar">
        <asp:Button ID="p1" runat="server" Text="Problems1" CssClass="sidebar_buttons"
         OnClientClick="Edit_Click()" />
        <asp:Button ID="p2" runat="server" Text="Problems2" CssClass="sidebar_buttons"
             />
        <asp:Button ID="p3" runat="server" Text="Problem3" CssClass="sidebar_buttons" />
        <asp:Button ID="p4" runat="server" Text="Problem4" CssClass="sidebar_buttons" />
        <asp:Button ID="p5" runat="server" Text="Problem5" CssClass="sidebar_buttons" />
        <asp:Button ID="p6" runat="server" Text="Problem6" CssClass="sidebar_buttons" />
        <asp:Button ID="p7" runat="server" Text="Problem7" CssClass="sidebar_buttons" />
    </div>
    <div id="gridview">
        <asp:GridView ID="GridView1" runat="server">
        </asp:GridView>
    </div>
      <div id="btnEdit" >
        <asp:Button ID="Edit" runat="server"  Text="Edit" /></div>
</div>

And CSS: 和CSS:

#wrap
{
     width: 800px;
     background-color: #99c;
}
#sidebar
{
    float: left;
    width: 125px;
    padding-top:10px;
    background-color: #C0C0C0;
}
#gridview
{
    float: right;
    width: 675px;
}

.sidebar_buttons
{
    margin-top: 10px;
    margin-left: 2px;
    margin-bottom: 10px;
    width: 120px;
 }

#btnEdit
{
   float: inherit;
}

In the aspx code, set the edit button to visible=false. 在aspx代码中,将编辑按钮设置为visible = false。 Go into the properties of the other buttons, go into the events and double click the 'Click' event and place code to make the button visible :) 进入其他按钮的属性,进入事件并双击“ Click”事件并放置代码以使按钮可见:)

Hope this helps 希望这可以帮助

first of all hide your edit button by inserting this property in your 首先,通过将此属性插入您的

#btnEdit
{
   float: inherit;
   display:none; //hide your edit button
}

then call jQuery function on click and show the edit button like 然后点击调用jQuery函数,并显示编辑按钮,例如

$("#button").click(function(){
     $("#btnEdit").show();
});

first you add display:none; 首先您添加display:none; to the css of btnEdit 到btnEdit的CSS

#btnEdit
{
    display:none;
}

Then you use Jquery to show the btnEdit when the "Problem1Button" is clicked (replace it by the ID of your button) 然后,当单击“ Problem1Button”时,您可以使用Jquery显示btnEdit(将其替换为按钮的ID)

<script>
$(document).ready(function () {
    $("#Problem1Button").click(function (event) {
    $("#btnEdit").show();            

    });
}
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM