Note that there are some explanatory texts on larger screens.

plurals
  1. POI need to change asp:buttons that are in a ListView from code behind
    primarykey
    data
    text
    <p>I have some buttons in list view and I need to change their CSS attributes through code behind so the color can be changed dynamically through functions.</p> <p>I get the following error:</p> <pre><code>**Error 6 The name 'SubDomainButton' does not exist in the current context.** </code></pre> <p>I would be happy being able to edit the CSS Class currently assigned to the buttons or reference the Button that is inside the ListView.</p> <p>I want to do something like...</p> <pre><code>SubDomainButton.Style.Add("border-color", (string) (Session["BorderFontColor"])); SubDomainButton.Style.Add("color", (string)(Session["BorderFontColor"])); SubDomainButton.Style.Add("background-color", (string)(Session["BackgroundColor"])); </code></pre> <p>HTML Segment:</p> <pre><code>&lt;asp:ListView ID="SubDomainListView" runat="server" DataKeyNames="ID" DataSourceID="SubDomainSqlDataSource" EnableModelValidation="True" OnItemCommand="SubDomainListView_ItemCommand"&gt; &lt;itemtemplate&gt; &lt;asp:Button ID="SubDomainButton" runat="server" Text='&lt;%# Eval("SubDomain") %&gt;' CommandText="click" CommandName="Select" CommandArgument='&lt;%# Eval("ID")%&gt;' UseSubmitBehavior="False" CssClass="button" /&gt; &lt;/itemtemplate&gt; &lt;selecteditemtemplate&gt; &lt;asp:Button ID="Button2" runat="server" Text='&lt;%# Eval("SubDomain") %&gt;' CommandText="click" CommandName="Select" CommandArgument='&lt;%# Eval("ID")%&gt;' UseSubmitBehavior="False" CssClass="buttoninact" Enabled="False" /&gt; &lt;/selecteditemtemplate&gt; &lt;layouttemplate&gt; &lt;div id="itemPlaceholder" runat="server"&gt; &lt;/div&gt; &lt;/layouttemplate&gt; &lt;/asp:ListView&gt; </code></pre> <p>CSS: /* Button Styles */</p> <pre><code>.button { -webkit-box-shadow: rgba(0,0,0,0.0.1) 0 1px 0 0; -moz-box-shadow: rgba(0,0,0,0.0.1) 0 1px 0 0; box-shadow: rgba(0,0,0,0.0.1) 0 1px 0 0; border: 1px solid; font-family: Lucida Grande,Tahoma,Verdana,Arial,sans-serif; font-size: 12px; font-weight: 700; padding: 2px 6px; height: 28px; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; text-decoration: underline; } /*Hover Styles*/ .button:hover { -webkit-box-shadow: rgba(0,0,0,0.0.1) 0 1px 0 0; -moz-box-shadow: rgba(0,0,0,0.0.1) 0 1px 0 0; box-shadow: rgba(0,0,0,0.0.1) 0 1px 0 0; border: 1px solid; font-family: Lucida Grande,Tahoma,Verdana,Arial,sans-serif; font-size: 12px; font-weight: 700; padding: 2px 6px; height: 28px; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; text-decoration: none; } .buttoninact { -webkit-box-shadow: rgba(0,0,0,0.0.1) 0 1px 0 0; -moz-box-shadow: rgba(0,0,0,0.0.1) 0 1px 0 0; box-shadow: rgba(0,0,0,0.0.1) 0 1px 0 0; border: 1px solid; font-family: Lucida Grande,Tahoma,Verdana,Arial,sans-serif; font-size: 12px; font-weight: 700; padding: 2px 6px; height: 28px; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; text-decoration: none; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload