1

我正在尝试将此相册集成到我的 asp.net 网站中。我正在从数据库中选择 3 张图片的 url,并显示来自特定相册的这 3 张图片。现在的问题是,如果用户有多个相册怎么办?它应该能够在页面上生成与该用户关联的数据库中一样多的 Jquery 专辑。

 <div class="image_stack" style="margin-left:300px" runat="server" >
 <img  id="photo1" class="stackphotos"  runat="server" clientidmode="static" >
    <img  id="photo2" class="stackphotos"  runat="server" clientidmode="static">
     <img   id="photo3" class="stackphotos"  runat="server" clientidmode="static" > 
     </div>

 public DataTable dt = new DataTable();
    dboperation dbo = new dboperation();

    protected void Page_Load(object sender, EventArgs e)
    {

        string q = "select photourl ,AlbumName  from PhotoAlbum where UserId=42";
        dt = dbo.Getdt(q);
        string a = dt.Rows[0]["photourl"].ToString();
        string b = dt.Rows[1]["photourl"].ToString();
        string c = dt.Rows[2]["photourl"].ToString();

        photo1.Src = a.Substring(1, a.Length - 1);
        photo2.Src = b.Substring(1, b.Length - 1);
        photo3.Src = c.Substring(1, c.Length - 1);

        q = "  select PhotoAlbum.AlbumId,PhotoAlbum.AlbumName from PhotoAlbum where UserId=42";

         dt = dbo.Getdt(q);
         drpalbum.DataSource = dt;
         drpalbum.DataTextField = "albumname";
         drpalbum.DataValueField = "albumid";
         drpalbum.DataBind();
    }

如果您需要查看更多代码,请告诉我。

4

3 回答 3

1

简单地使用“div”

其中像这样

//HTML (.aspx)
<div id="MyDiv" runat="server" > </div>

//CodeBehind (.aspx.cs)
MyDiv.innerHTML = "Your HTML & CSS or Script code here CODE";

它将应用于整个 div

编辑1:

using System.Web.UI.HtmlControls;

上面导入

于 2013-03-29T10:19:34.413 回答
1

你需要做的是在你的页面上有一个 HTML 元素,像这样与服务器通信,

与光子几乎相同

//HTML - Does not have to be div could be anything like <p>, <div>, <a> etc.
<span id="SomeHTMLElement" runat="server" ></span>

//C#
SomeHTMLElement.innerHTML = "Any text you want to your page (text, HTML, script and/or CSS";
于 2013-03-29T13:23:19.200 回答
0

checkout this to generate HTML and CSS dynamically in asp.net

http://www.dotnetperls.com/htmltextwriter

于 2013-03-29T10:32:56.763 回答