c# - Repeater asp.net tag not working -
c# - Repeater asp.net tag not working -
i have problem repeater tag of asp.net. doesn't generate html code when page running. i'm trying utilize generate list of tag slideshow, here asp code:
<asp:repeater id="foto" runat="server"> <itemtemplate> <img src='<%# (string)container.dataitem %>'/> </itemtemplate> </asp:repeater>
and here code behind:
protected void page_load(object sender, eventargs e) { if (ispostback) { int num = directory.getfiles(@"c:\users\paolo\desktop\podisti\slideshow\" + request.querystring["cartella"]).length; list<string> elencourl = new list<string>(); (int = 1; <= num; i++) elencourl.add(@"slideshow\" + request.querystring["cartella"] + "00" + + "_jpg.jpg"); foto.datasource = elencourl; //può essere advertisement esempio united nations array o una list di stringhe foto.databind(); } }
edit: give thanks answer, if isn't solution of problem: page i've created test which, click of 2 linkbuttons, redirect same page different querystring repeater can create different src attributes img tag every time. postback in here prevent error in first load of page (where querystring null), changed when solve problem.
the main problem repeater doesn't work, if check code of page during execution:
<div style="width:500px;height:400px"> <div class="fotorama"> /*the repeater doesn't create <img> tags*/ </div> </div>
if (ispostback)
means code executed if posted page, want show default, not during postback. prepare to:
if (!ispostback)
if that's case.
also, should never seek reach outside web app folder folders/files, because won't accessible on server. never hardcode paths this!
c# html asp.net image repeater
Comments
Post a Comment