PlaceHolder Example in ASP.NET using C#

PlaceHolder Example in ASP.NET using C#

Posted in : ASP.Net Posted on : November 26, 2010 at 6:24 PM Comments : [ 0 ]

In this article we will introduce with PlaceHolder control in ASP.NET using C#.

PlaceHolder Example in ASP.NET using C#

PlaceHolder Web server control in ASP.NET is used to added the controls at run time. In this example we take four PlaceHolder and each PlaceHolder contains a hyperlink. We create a HyperLink in C# and added to it at runtime.

PlaceHolder.aspx (Design Page):

PlaceHolder.aspx (source code):

<%@ Page Title="" Language="C#" MasterPageFile="~/RoseindiaMaster.master" 
AutoEventWireup="true" CodeFile="PlaceHolder.aspx.cs" Inherits="PlaceHolder" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
<h2 style="color:Green">PlaceHolder in ASP.NET 4 , C#</h2>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
<br />
<br />
<asp:PlaceHolder ID="PlaceHolder2" runat="server"></asp:PlaceHolder>
<br />
<br />
<asp:PlaceHolder ID="PlaceHolder3" runat="server"></asp:PlaceHolder>
<br />
<br />
<asp:PlaceHolder ID="PlaceHolder4" runat="server"></asp:PlaceHolder>

PlaceHolder.aspx.cs (C# code file):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
public partial class PlaceHolder : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
HyperLink hyperlink1 = new HyperLink();
hyperlink1.Text = "Devmanuals";
hyperlink1.NavigateUrl = "";
HyperLink hyperlink2 = new HyperLink();
hyperlink2.Text = "Google";
hyperlink2.NavigateUrl = "";
HyperLink hyperlink3 = new HyperLink();
hyperlink3.Text = "Yahoo";
hyperlink3.NavigateUrl = "";
HyperLink hyperlink4 = new HyperLink();
hyperlink4.Text = "Roseindia";
hyperlink4.NavigateUrl = "";


Download source code
Go to Topic «PreviousHomeNext»

Your Comment:

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image

Tutorial Topics