I have textbox and HtmlEditorExtender inside the Repeater Item, the rendering went all wrong! Anybody has any idea how to solve this?
Below is the sample code.
<asp:Repeater ID="rptQuestion" runat="server">
<ItemTemplate>
<div class="row">
<div class="colTitle">
Question <%# Eval("sequence") %>
</div>
<div class="colColon">:</div>
<div class="colContent">
<asp:TextBox ID="tbxQuestion" runat="server" Text='<%# Eval("questionText") %>'
TextMode="MultiLine" Columns="50" Rows="10" CssClass="textbox">
</asp:TextBox>
<ajaxToolkit:HtmlEditorExtender ID="tbxQuestion_HtmlEditorExtender" runat="server"
TargetControlID="tbxQuestion" DisplaySourceTab="true">
</ajaxToolkit:HtmlEditorExtender>
</div>
</div>
<asp:Repeater ID="rptAnswer" runat="server" DataSource="<%# GetAnswers(Container.DataItem) %>">
<ItemTemplate>
<div class="row">
<div class="colTitle" style="text-align:right">
Answer <%# Eval("sequence") %>
</div>
<div class="colColon">:</div>
<div class="colContent">
<asp:TextBox ID="tbxAnswer" runat="server" Text='<%# Eval("answerText") %>'
TextMode="MultiLine" Columns="50" Rows="10" CssClass="textbox">
</asp:TextBox>
<ajaxToolkit:HtmlEditorExtender ID="tbxAnswer_HtmlEditorExtender" runat="server"
TargetControlID="tbxAnswer" DisplaySourceTab="true">
</ajaxToolkit:HtmlEditorExtender>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
<SeparatorTemplate>
<div class="row"> </div>
</SeparatorTemplate>
</asp:Repeater>
Solved this by added a dummy HTML editor outside of the UpdatePanel to enable correct rendering all the time. The HTML editor is set to absolute and away from the screen.
Related
so i have this bit of asp here:
<asp:Panel runat="server" ID="pnlNavigator" CssClass="panel panel-primary">
<div class="panel-body" style="width:100%">
<div style="display:inline-block" >
<br /><br />
<div class="container" style="display:inline-block">
<asp:TextBox runat="server" Enabled="false" Width="33%" TextMode="MultiLine" Text=" ***Teacher Training, CPD, Mentor Training***">
</asp:TextBox>
<asp:TextBox runat="server" Enabled="false" Width="33%" TextMode="MultiLine" Text="***Sports Science, steps, FMS facilitator***">
</asp:TextBox>
<asp:TextBox runat="server" Enabled="false" Width="33%" TextMode="MultiLine" Text="***Professional Development, Consultant***">
</asp:TextBox>
</div>
</div>
</div>
</asp:Panel>
and basically they aren't filling up the entire panel,they're only reaching about half way then starting a new line underneath, any help?
Bootstrap .css adds a pixel ::before and ::after the elements so the combined width of the three textareas exceeds 100%.
1st solution: decrease the width by 1%
<asp:TextBox runat="server" Enabled="false" Width="32%" TextMode="MultiLine" Text="***Sports Science, steps, FMS facilitator***">
</asp:TextBox>
2nd solution: use bootstrap grid system to control layout
<asp:Panel runat="server" ID="pnlNavigator" CssClass="panel panel-primary">
<div class="panel-body">
<%-- style="width:100%">--%>
<div class="container-fluid">
<%-- style="display:inline-block" >--%>
<%-- <br /><br />--%>
<div class="row">
<%-- style="display:inline-block">--%>
<div class="col-sm-4">
<asp:TextBox runat="server" Enabled="false" Width="100%" TextMode="MultiLine" Text=" ***Teacher Training, CPD, Mentor Training***">
</asp:TextBox>
</div>
<div class="col-sm-4">
<asp:TextBox runat="server" Enabled="false" Width="100%" TextMode="MultiLine" Text="***Sports Science, steps, FMS facilitator***">
</asp:TextBox>
</div>
<div class="col-sm-4">
<asp:TextBox runat="server" Enabled="false" Width="100%" TextMode="MultiLine" Text="***Professional Development, Consultant***">
</asp:TextBox>
</div>
</div>
</div>
</div>
</asp:Panel>
I have a repeater set up in Visual Studio to try and grab the latest 3 blog titles from the database and show the associated image along with the title, intro and a link.
However the parent div of each blog needs to have a different ID.
Currently I have the following code but it's not working because I've since found out you can't have an itemtemplate followed by an alternating item template followed by another item template.
I there any workaround to this?
<asp:Repeater runat="server" ID="repeaterNews1" DataSourceID="SQLDataNews1">
<ItemTemplate>
<div id="blog1">
<div class="col-xs-12">
<asp:Image runat="server" ID="Image1" ImageUrl='<%# Eval("NewsStoryImage") %>'/>
<div class="blogContent">
<div class="container">
<h2>Our Blog</h2>
<p><asp:Label runat="server" ID="Label1" Text='<%# Eval("PageTitle") %>'></asp:Label></p>
<p><asp:Label runat="server" ID="Label2" Text='<%# Eval("Content1") %>'></asp:Label></p>
Read More
</div>
</div>
</div>
</div>
</ItemTemplate>
<AlternatingItemTemplate>
<div id="blog2">
<div class="col-xs-12">
<asp:Image runat="server" ID="Image2" ImageUrl='<%# Eval("NewsStoryImage") %>'/>
<div class="blogContent">
<div class="container">
<h2>Our Blog</h2>
<p><asp:Label runat="server" ID="Label1" Text='<%# Eval("PageTitle") %>'></asp:Label></p>
<p><asp:Label runat="server" ID="Label2" Text='<%# Eval("Content1") %>'></asp:Label></p>
Read More
</div>
</div>
</div>
</div>
</AlternatingItemTemplate>
<ItemTemplate>
<div id="blog3">
<div class="col-xs-12">
<asp:Image runat="server" ID="Image3" ImageUrl='<%# Eval("NewsStoryImage") %>'/>
<div class="blogContent">
<div class="container">
<h2>Our Blog</h2>
<p><asp:Label runat="server" ID="Label1" Text='<%# Eval("PageTitle") %>'></asp:Label></p>
<p><asp:Label runat="server" ID="Label2" Text='<%# Eval("Content1") %>'></asp:Label></p>
Read More
</div>
</div>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
No, you cannot create a third template.
What you can do is make sure the ID's are still unique by using Container.DataItemIndex
<ItemTemplate>
<div id="blog<%# Container.DataItemIndex %>"></div>
</ItemTemplate>
i use listview and ajax in asp.net web form ... in part of form, display comments and readers can positive score or negative score but while user click on positive or negative button, update value is not display unless page is refresh.
please help me
<ItemTemplate>
<div class="row comm_info_bar ">
<div class="col-md-5 RightDisplay"><%# Eval("name") %></div>
<div class="col-md-5 comm_info_date"><%# Eval("date") %></div>
<asp:LinkButton ID="negBtn" class="glyphicon glyphicon-minus voteCommentIcon voteContNeg text-danger smallGlyph" runat="server" CommandName="negative" CommandArgument='<%#Eval("id")%>' />
<asp:Label ID="lblnegative" name="lblnegative" class=" voteNumNeg" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "negative") %>'></asp:Label>
<asp:LinkButton ID="posBtn" class="glyphicon glyphicon-plus voteCommentIcon voteContNeg text-success smallGlyph" runat="server" CommandName="positive" CommandArgument='<%#Eval("id")%>' />
<asp:Label ID="lblpositive" class="voteNumPos" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "positive") %>'></asp:Label>
</div>
<div class="row">
<div class="col-md-12 comments"><%# Eval("text") %></div>
</div>
</ItemTemplate>
</asp:ListView>
</ContentTemplate>
</asp:UpdatePanel>
I have an Asp.net DataList control in my page. It is currently having repeatcolumns set to 4 which will give me 4 columns in each row. But I want to make this responsive and set the value to 1 for smaller screen sizes. Below is my asp.net control:
<asp:DataList runat="server" RepeatDirection="Horizontal" RepeatColumns="4" ID="dd" class="vex-res">
How can I achieve this?
You cannot make DataList to be responsive, because it renders as Table.
Instead, you need to use ListView with bootstrap (or some other responsive framework).
<asp:ListView ID="ListView1" runat="server" ...>
...
<ItemTemplate>
<div class="row">
<div class="col-md-4"><%# Eval("Name") %></div>
<div class="col-md-4"><%# Eval("Email") %></div>
<div class="col-md-4"><%# Eval("Address") %></div>
</div>
</ItemTemplate>
</asp:ListView>
This Work My Home :
<asp:DataList ID="dlCustomers" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow" CssClass="row">
<ItemTemplate>
<%-- <div class="row">--%>
<div class="col-sm-4"><!--THUMBNAIL#2-->
<div class="panel-body">
<span class="label label-warning"><%# Eval("status")%></span>
<div class="thumbnail label-success">
<asp:Image ID="Image1" runat="server" ImageUrl='<%# "~/" +Eval("image1").ToString().Trim() %>' Width="150px" Height="150px" />
<div class="caption"><h4>Rp.<small> <%# Eval("harga")%></small></h4>
<strong><%# Eval("judul") %></strong>
<p>
<small>LT:<strong> <%# Eval("luastanah")%> m2</strong> </small> <small> LB : <strong> <%# Eval("luasbangunan")%> m2</strong> </small>
<small>Setifikat : <strong><%# Eval("sertifikasi")%></strong> </small> <br />
<small> Kamar : <strong><%# Eval("kamartidur")%></strong> </small><br />
<small> Kamar Mandi : <strong><%# Eval("kamarmandi")%></strong> </small>
</p>
Lihat Details
</div>
</div>
</div>
</div>
<%--</div>--%>
</ItemTemplate>
</asp:DataList>
Responsive using bootstrap 3.3.6 ..
Coming to this a little late but I found an asp:repeater works well and no additional CSS is required to get the layout repeating horizontally.
<div class="container">
<div class="row">
<asp:Repeater ID="myRepeater" runat="server" DataSourceID="myDataSourceID">
<ItemTemplate>
<div class="col-sm-4">
<%# Eval("itemID")%><br />
<%# Eval("itmName")%>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
</div>
I realise that this will result in the total columns in one row adding up to more than 12 but as this will just wrap to the line underneath it shouldn't really matter.
Reference: https://stackoverflow.com/questions/23502342/bootstrap-3-grid-does-it-really-matter-how-many-columns-are-in-a-row
You can also try setting RepeatLayout="Flow". That will cause your datalist to render as a series of <div> elements, which will behave more responsively.
<asp:DataList ID="DataList1" runat="server" OnItemDataBound="uxPosts_ItemDataBound1" cssClass="row" RepeatLayout="Flow" RepeatDirection="Horizontal">
<ItemTemplate>
<div class="col-sm-3 col-md-3 col-lg-3"><%# Eval("Name") %></div>
<div class="col-sm-3 col-md-3 col-lg-3"><%# Eval("Email") %></div>
<div class="col-sm-3 col-md-3 col-lg-3"><%# Eval("Address") %></div>
<div class="col-sm-3 col-md-3 col-lg-3"><%# Eval("Phone") %></div>
</ItemTemplate>
</asp:DataList>
<asp:DataList ID="uxPosts" runat="server" OnItemDataBound="uxPosts_ItemDataBound1" cssClass="row" RepeatLayout="Flow" RepeatDirection="Horizontal">
<ItemTemplate>
<a id="uxLink" runat="server" class="txt_link">
<div class="col-xs-4 col-sm-4 col-md-4 " style="text-align:center;" >
<asp:Label ID="Label2" runat="server" Text='<%# Eval("Descripcion","{0:d}") %>'></asp:Label>
</div>
<div class="col-xs-4 col-sm-4 col-md-4 " style="text-align:center;" >
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Descripcion","{0:d}") %>'></asp:Label>
</div>
<div class="col-xs-4 col-sm-4 col-md-4 " style="text-align:center;" >
<asp:Label ID="Label4" runat="server" Text='<%# Eval("Descripcion","{0:d}") %>'></asp:Label>
</div>
</a>
</ItemTemplate>
</asp:DataList>
You can do it with asp literal, write the code in the string and add it to literal,
suppose you want to show items dynamically
you can do it this way
Add html
<div class="any_css_class">
<div class="any_css_class2">
<asp:Literal ID="Literal1" runat="server"></asp:Literal>
</div>
</div>
and in your cs file
string htmlcode = ""; //code you want in your html
foreach (FetchedDetails fd in yourListOfItems)
{
htmlcode += "<div class='content content-1' onclick=\"dosomething('" + fd.itemId + "')\"> " +
"<div class='fab fa-any_icon'></div> " +
"<h2>" + fd.anyAttribute + "</h2> ";
}
Literal1.Text = htmlcode; //add code to literal
This will do it. It will be responsive but you have to define your css properly :)
<asp:DataList ID="uxPosts" runat="server" OnItemDataBound="uxPosts_ItemDataBound1" cssClass="row" RepeatLayout="Flow" RepeatDirection="Horizontal">
<ItemTemplate>
<a id="uxLink" runat="server" class="txt_link">
<div class=" col-xs-6 col-sm-4 col-md-3 col-lg-3 " style="text-align:center;" >
<div class="pnlborde">
<div class="encabezadofondo">
<asp:Label ID="Label2" runat="server" Height="38px" width="150px" Text='<%# Eval("Descripcion","{0:d}") %>'></asp:Label>
</div>
<br />
<asp:Image ID="uxImage" runat="server" width="65%" Height="90%" align="center" />
<br /><br />
</div>
<br />
</div>
</a>
</ItemTemplate>
</asp:DataList>
I've got a problem here with a div not being placed that way I'd like it to.
This is the ASP code I'm using:
<asp:ListView ID="categoriesListView" runat="server">
<LayoutTemplate>
<div class="main" runat="server">
<div ID="itemPlaceholder" class="sub" runat="server">
</div>
</div>
</LayoutTemplate>
<EmptyDataTemplate>
<div class="main" runat="server">
<div class="sub" ID="itemPlaceholder" runat="server">
No data was returned.
</div>
</div>
</EmptyDataTemplate>
<ItemTemplate>
<asp:Image AlternateText='<%# Eval("CategoryName") %>' ID="Image1" runat="server" ImageUrl='<%# Eval("CategoryImgUrl", "~/Images/{0}") %>' />
<asp:Label ID="ProductNameLabel" runat="server" Text='<%# Eval("CategoryName") %>' />
</ItemTemplate>
</asp:ListView>
I was expecting results like this:
<div class="main">
<div class="sub">
...
</div>
<div class="sub">
...
</div>
<div class="sub">
...
</div>
...
</div>
The result was one big div "main" containing everything, with no "sub" divs.
If I added the itemPlaceholder one level deeper, the same thing would happen, now with 1 "sub" div and everything pushed in there. How do I solve this?
Change it to look like this:
<LayoutTemplate>
<div class="main" runat="server">
<div ID="itemPlaceholder" runat="server">
</div>
</div>
</LayoutTemplate>
<EmptyDataTemplate>
<div class="main" runat="server">
<div class="sub" ID="itemPlaceholder" runat="server">
No data was returned.
</div>
</div>
</EmptyDataTemplate>
<ItemTemplate>
<div class="sub" >
<asp:Image AlternateText='<%# Eval("CategoryName") %>' ID="Image1" runat="server" ImageUrl='<%# Eval("CategoryImgUrl", "~/Images/{0}") %>' />
<asp:Label ID="ProductNameLabel" runat="server" Text='<%# Eval("CategoryName") %>' />
</div>
</ItemTemplate>