我是Jquery和javascript的新手。我在我的as.net项目中使用Jquery UI选项卡。我的标签内容是dynamic.so,我使用SQL Server来保存并检索它们。我有一个类来建立基于点击特殊按钮的标签。这是我的课:点击加载jquery标签内容
public class TabBuilder{
public string Build(int ServiceId)
{
string title = " <div class='demo'><div id='tabs' onclick='alert(yes)'><ul>\n";
string content = "";
DataTable select = new DataTable();
ServicesBLL ser = new ServicesBLL();
select = ser.FormsSelTabs(ServiceId);
int i = 1;
foreach (DataRow row in select.Rows)
{
title += createTitle(row["LinkName"].ToString(), i);
content += createContent(row["LinkHref"].ToString(), i);
i++;
}
title += "</ul>\n";
content += "</div></div>";
return title + content;
}
private string createTitle(string title, int i)
{
string htm = "<li><a id='tab{0}' href='#tabs-{1}'>{2}</a></li>\n";
htm = string.Format(htm, i,i, title);
return htm;
}
private string createContent(string content, int i)
{
string htm = "<div id='tabs-{0}'><iframe dir='rtl' frameborder='0' height='600px' width='100%' src='{1}'></iframe></div>\n";
htm = string.Format(htm, i, content);
return htm;
}}
在我的aspx页面
我有一个文本(LtrTabs)来显示标签和aspx.cs代码,我有这样的代码来构建标签:
protected void btnEntities_Click(object sender, EventArgs e)
{
ServiceID = 1;
TabBuilder tab = new TabBuilder();
LtrTabs.Text = tab.Build(ServiceID);
}
我需要懒加载标签,但我不知道如何实现它。我看到了一些例子,但是没有一个使用数据库来加载内容。
作为更一般的说明,你真的不应该在服务器端代码中输出HTML。尤其是_compiled_服务器端代码。如果你的平面设计师想要改变iframe的大小呢? – 2011-10-08 13:22:26