将控件动态添加到母版页中的contentplaceholder时,asp.net母版页脚中的问题. [英] Problems in asp.net master page footer when adding controls dynamically to contentplaceholder in master page.
问题描述
我和我已经建立了一个关于论坛的网站,例如(提问和回答问题).现在为美观起见,我添加了一个CSS模板(CSS模板的某些部分,页眉和页脚..在我的main.aspx中,我想在链接按钮上动态显示用户提出的所有问题.但是我有一个问题,我的页脚显示在页眉的正下方(就像在母版页的设计中显示的那样-> 1.页眉,2.contentplaceholder,3.页脚.)我需要添加动态生成的控件到contentplaceholder,并在页尾显示页脚.请帮助.我的母版页代码是....
HI iam yogesh and i have made a website on forums,ie (to ask questions and reply to questions). now for good looks i have add a css template(some part of css template, header and footer.. In my main.aspx i want to display all questions asked by users on a link button dynamically.. i have successfully did this job. But i have a problem that, my footer is displaying immediately below the header( as it looks in the design of master page->1. the header,2. contentplaceholder,3. footer.) I need to add the dynamically generated controls to the contentplaceholder, and the at end the footer should be displayed.please help m.. my code for master page is....
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="forum.master.cs" Inherits="ADVANCED_FORUM.forum" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Advantage by Free Css Templates</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="header" style="height: 273px">
<div id="logo" style="width: 137px; height: 55px">
<h1><a href="#">Forums</a></h1>
<h2><a href="http://www.csstemplatesforfree.com/">By Yogesh Sharma</a></h2>
</div>
<div id="menu" style="height: 118px">
<ul>
<li class="active"><a href="#" title="">Homepage</a></li>
<li><a href="#" title="">About Us</a></li>
<li><a href="main.aspx" title="">View all questions</a></li>
<li><a href="#" title="">Unanswered question</a></li>
<li><a href="#" title="">Ask a question</a></li>
</ul>
</div>
</div>
<form id="formm" runat="server">
<asp:ContentPlaceHolder ID ="cp1" runat="server">
</form>
<div id="footer" style="height: 66px">
<p id="legal">Copyright © 2007 Advantage. All Rights Reserved. Designed by <a href="http://nicecsstemplates.com/" title="nice free css templates">CSS Templates For Free</a>.</p>
<p id="links"><a href="#">Privacy Policy</a> | <a href="#">Terms of Use</a></p>
</div>
</body>
</html>
并且用于动态生成链接按钮的代码是
AND the code for dynamically generated link button is
methods.createcon("forum");
SqlCommand chkcmd = new SqlCommand("select q.*,r.* from questinfo q join reginfo r on q.quid= r.userid order by qdate desc", methods.connection);
SqlDataReader dispdr = chkcmd.ExecuteReader();
if (dispdr.HasRows)
{
t=70
while (dispdr.Read())
{
string mtop = t.ToString() + "px";
LinkButton lnk1 = new LinkButton();
lnk1.Style["position"] = "absolute";
lnk1.Style["left"] = "170px";
lnk1.Style["top"] = mtop;
lnk1.ID = "lnkbtn" + dispdr["qid"].ToString() + "_" + dispdr["quid"].ToString();
lnk1.Text = dispdr["question"].ToString();
lnk1.Font.Bold = true;
lnk1.Font.Italic = true;
lnk1.Font.Size = 10;
lnk1.ForeColor = Color.Navy;
t=t+50;/to set the top property of controls/
((Panel((ContentPlaceHolder)Master.FindControl("cp1")).FindControl("panel1")).Controls.Add(lnk1);
((Panel)((ContentPlaceHolder)Master.FindControl("cp1")).FindControl("Panel1")).Height = t + 60;
我将控件放置在main.aspx页上的面板上.而且我正在设置面板的高度.这是什么问题??
请帮助我,并提供一些解决方案或其他建议..
Iam placing the controls on a panel which is on the main.aspx page. and also i am setting the hieght of panel.. WHAT"S wrong with this.?
Please help me and give some solution or some other suggestions..
推荐答案
我认为问题出在您的标记错误中.关闭< asp:contentplaceholder xmlns:asp =#unknown">并检查其他标签.
I think that problem is in your errors in markup. Close "<asp:contentplaceholder xmlns:asp="#unknown">" and check other tags.
这篇关于将控件动态添加到母版页中的contentplaceholder时,asp.net母版页脚中的问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!