?
Solved

Access parent control on button click

Posted on 2010-01-11
3
Medium Priority
?
406 Views
Last Modified: 2012-05-08
On button click, I want to access the parent (a div) of the button control. How can I do that?

On button click, in addition to performing some db operations, I have to change the div style too.
<div id="Main" runat="server">
   <asp:button id="btnSave" runat="server" onclick="btnSave_Clicked" text="Save" />
</div>

Open in new window

0
Comment
Question by:dj_user2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 36

Accepted Solution

by:
Miguel Oz earned 668 total points
ID: 26290629
0
 
LVL 3

Assisted Solution

by:infochandru
infochandru earned 668 total points
ID: 26290663
Hope this helps you

    protected void btnSave_Click(object sender, EventArgs e)
    {
        HtmlGenericControl div = (HtmlGenericControl)btnSave.Parent;
        div.Style.Add("border", "5px");
        div.Style.Add("border-color", "Red");

    }
0
 
LVL 4

Assisted Solution

by:maheshsnkr
maheshsnkr earned 664 total points
ID: 26290680
hi dj_user2,

try the below code snippet

 protected void btnSave_Clicked(object sender, EventArgs e)
    {  
        HtmlContainerControl ParentDiv = (HtmlContainerControl)btnSave.Parent;
        ParentDiv.Style.Add(HtmlTextWriterStyle.BackgroundColor, "#ffff99;");
        // Just put a width to see whether the applied background-color is affected or not.
        // You can use the above 2 lines of code.
        ParentDiv.Style.Add(HtmlTextWriterStyle.Width, "500px");
       
    }
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question