我是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