How To Access Div, Iframe Html Controls Using code behind

How To Access Div, Iframe Html Controls Using code behind

You want to access div or Iframe Html controls using code behind. In you can do this by adding extra attribute runat="server" to those elements. Here we will see how to access and control the rendering of div and iframe using c# and code.

DIV Runat server Example: let's access Html div control in code behind.

<div id="topLeader" runat="server">

Access Div at server side using code behind.

protected void Button1_Click(object sender, EventArgs e)
    topLeader.Visible = false;    
  } Iframe Example

It's not a good practice to use Iframe in web applications. But, you may want to access the properties of Iframe or load the pages into Iframe dynamically. Sometimes you want to load the Iframe based on condition and load the website into it accordingly.

You can access the src element of Iframe by making Iframe to run at server side iframe src code behind Let's see how to access src of Iframe. code to access src of Iframe
 protected void Button1_Click(object sender, EventArgs e)

Tags: access html control textbox element value at code behindhtml without using tables tableless html table less html css tableless Create Html ControlsOnline html editor online JavaScript editorC# HtmlTextWriter How to display HTML contentsBasic HTML5 TagsPaypal purpose code IndiaHTML5 With DataBaseRegularExpression remove html tagsHTML5 Tutorial


My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.

I'm Satalaj.