Creating Bootstrap-Datepicker with multiple asp:Repeater TextBoxes - c#

I am creating form using an asp:Repeater, each object of the repeater has one textbox that will need it's own unique bootstrap-datepicker linked to it. (the datepicker is a javascript addon to twitter-bootstrap 2.3.2 found here: http://www.eyecon.ro/bootstrap-datepicker -- Wanted to add that the link is safe, but there is no real need to view the page in regards to the question)
My problem is that I am not able to use the asp.net clientid to correctly target the text boxes.
aspx code:
<asp:Repeater ID="repList" runat="server">
<HeaderTemplate>
<ul class="gridul">
<li class="gridli userrole"><span class="short liheader">Jenz ID</span></li>
<li class="gridli"><span class="long liheader">Name</span></li>
<li class="gridli"><span class="short liheader">S/S/F</span></li>
<li class="gridli"><span class="short liheader">Date</span></li>
<li class="gridli"><span class="long liheader">Payment Type</span></li>
<li class="gridli"><span class="mid liheader">Sent to B.O.</span></li>
</ul>
</HeaderTemplate>
<ItemTemplate>
<ul class="gridul">
<li class="gridli userrole"><span class="short"><%# Eval("jenzabar_id") %></span></li>
<li class="gridli"><span class="long"><%# Eval("first_name") %>&nbsp<%# Eval("last_name") %></span></li>
<li class="gridli"><span class="short"><%# Eval("student_staff_faculty") %></span></li>
<li class="gridli"><span class="short"><%# Eval("reservation_date") %></span></li>
<li class="gridli"><span class="long"><asp:TextBox ID="PayType" runat="server" Text='<%# Eval("payment_type") %>' /></span></li>
<li class="gridli"><span class="mid"><asp:TextBox ID="SentBo" runat="server" Text='<%# Eval("sent_to_bo") %>' /></span></li>
</ul>
<asp:HiddenField ID="hidJenz" runat="server" Value='<%# Eval("jenzabar_id") %>' />
<asp:HiddenField ID="hidPayType" runat="server" Value='<%# Eval("payment_type") %>' />
<asp:HiddenField ID="hidSentBo" runat="server" Value='<%# Eval("sent_to_bo") %>' />
</ItemTemplate>
</asp:Repeater>
The textbox being targeted is:
<asp:TextBox ID="SentBo" runat="server" Text='<%# Eval("sent_to_bo") %>' />
In my scripts.js I can target an individual textbox by viewing the aspx source and copying in the generated id such as "ctl00_MainContent_repList_ctl01_SentBo" but I cannot figure out how to use <%# SentBo.ClientID %> with the repeater. It just doesn't work.
Example:
$(function () {
$('ctl00_MainContent_repList_ctl01_SentBo').datepicker();
})
is successful
$(function () {
$('<%#= SentBo.ClientID %>').datepicker();
})
is not

Did more digging. Found the answer, finally.
Replace:
$('ctl00_MainContent_repList_ctl01_SentBo').datepicker();
with:
$(this).find("input[type=text][id*=SentBo]").datepicker();

Related

Gallery is not showing after uploading into live site using ASP.NET C#

Below I am calling my gallery using Datalist in localhost gallery is showing and live site not showing.
<asp:DataList ID="dlImages" runat="server">
<ItemTemplate>
<ul>
<li><a href="#cube">
<asp:Image ID="Image2" runat="server" class="cubeHide" ImageUrl='<%# Bind("ImageName", "/GalleryImages/{0}") %>' />
</a>
<div class="label_text">
</div>
</li>
</ul>
</ItemTemplate>
</asp:DataList>
1.Change ImageUrl from this:
ImageUrl='<%# Bind("ImageName", "/GalleryImages/{0}") %>'
To this:
ImageUrl='<%# Bind("ImageName", "~/GalleryImages/{0}") %>'
2.Make sure you have a folder called GalleryImages in the root of your website with the relevant image files.
I added simply ~ then resolve my issue:
ImageUrl='<%# Bind("ImageName", "~/GalleryImages/{0}") %>'

Showing Data in a specific format inside asp repeater

I am using a repeater control which have my data retrieved from database. I need to show them in the following format in the HTML.
<ul>
<li>
<div>content 1</div>
<div>content 2</div>
<div>content 3</div>
<div>content 4</div>
</li>
<li>
<div>content 5</div>
<div>content 6</div>
<div>content 7</div>
<div>content 8</div>
</li>
</ul>
I need to put a li tag for each 4 items that are bound from the repeater.
if any of you guys know how to achieve this, please let me know. Thanks.
Try Below Code- Data-Binding Expressions - Eval()
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<ul>
</HeaderTemplate>
<ItemTemplate>
<li>
<div><%# Eval("content1") %></div> // content1 is DB Column Name
<div><%# Eval("content2") %></div> // content2 is DB Column Name
<div><%# Eval("content3") %></div> // as so on for all content... till 8
<div><%# Eval("content4") %></div>
</li>
<li>
<div><%# Eval("content5") %></div>
<div><%# Eval("content6") %></div>
<div><%# Eval("content7") %></div>
<div><%# Eval("content8") %></div>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>

Multilingual pages and dynamic multilingual content

I am creating a web app that has multilingual pages in dynamic multilingual contents or pages as well. The problem is actually with multilingual contents. When I use visible prop or the repeater component then it works well, but the problem when writes a lot of code, I think there must be a simpler way for this?
<!--Turkish-->
<asp:ListView runat="server" ID="lvListAllProdsTr">
<ItemTemplate>
<div class="gallery_box">
<a rel="lightbox[portfolio]" href='<%# Eval("ImgUrl") %>' title='<%# Eval("ProdNameTr") %>'>
<img src='<%# Eval("ImgUrl") %>' />
</a>
<h3>
<a href="#">
<%# Eval("ProdNameTr") %>
</a>
</h3>
<a href="#" class="more">
<asp:Literal ID="ltrDetayTr" Text="Detay" runat="server" /></a>
<div class="cleaner">
</div>
</div>
</ItemTemplate>
</asp:ListView>
<asp:DataPager ID="dpTr" runat="server" PagedControlID="lvListAllProdsTr" PageSize="10">
<Fields>
<asp:NumericPagerField />
</Fields>
</asp:DataPager>
<!--Turkish-->
<!--Russian-->
<asp:ListView runat="server" ID="lvListAllProdsRu">
<ItemTemplate>
<div class="gallery_box">
<a rel="lightbox[portfolio]" href='<%# Eval("ImgUrl") %>' title='<%# Eval("ProdNameRu") %>'>
<img src='<%# Eval("ImgUrl") %>' />
</a>
<h3>
<a href="#">
<%# Eval("ProdNameRu") %>
</a>
</h3>
<a href="#" class="more">
<asp:Literal ID="ltrDetayTr" Text="Detay" runat="server" /></a>
<div class="cleaner">
</div>
</div>
</ItemTemplate>
</asp:ListView>
<asp:DataPager ID="dpRu" runat="server" PagedControlID="lvListAllProdsRu" PageSize="10">
<Fields>
<asp:NumericPagerField />
</Fields>
</asp:DataPager>
<!--Russian-->
instead of Eval("ProdNameTr") how about calling a method for example :
GetProductName(Container.DataItem)
inside this method you read the current locale (if you know by then from the culture or something) and return the appropriate value

how to get top record from datalist

how to get top of record by name in datalist..
<asp:DataList ID="dlOtherTrends" runat="server" OnItemDataBound="dlOtherTrends_OnItemDataBound">
<ItemTemplate>
<li><img id="imgPost" runat="server" width="70">
<span><asp:Label ID="lblPostName" runat="server"></asp:Label></span></li>
</ItemTemplate>
</asp:DataList>
now this is the list page..
<asp:DataList ID="dlPost" runat="server" OnItemDataBound="dlPost_OnItemDataBound">
<ItemTemplate>
<article>
<h1><asp:Label ID="lblPostName" runat="server" Text="Label"></asp:Label></h1><a name="<%# Eval("NAME") %>"></a>
<span class="posted">Posted on <asp:Label ID="lblPostDate" runat="server" Text="Label"></asp:Label> by Editor</span>
<p><img id="imgPost" runat="server" width="540"></p>
<p><div id="DivDescr" runat="server"></div></p>
<p> </p>
<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style ">
<a class="addthis_button_facebook_like"<%="fb:like:layout"%>="button_count"></a>
<a class="addthis_button_tweet"></a>
<a class="addthis_button_google_plusone"<%="g:plusone:size"%>="medium"></a>
<a class="addthis_counter addthis_pill_style"></a>
</div>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4fc6ff7e30646c29"></script>
<!-- AddThis Button END -->
</article>
</ItemTemplate>
</asp:DataList>
by clicking of imgPost and lblPostName i need the same record in second one....the problem is all the records are coming in same page but i want to show selected one first
select top name from urdataTable desc
this will do if you are working with sql server

ASP.NET outputting <br> tags?

I'm working on a website built in .net and its outputting linbreaks after each span for some reason. The code thats outputting the line breaks is
<asp:DataList ID="DL_Items" runat="server" DataKeyField="ProductID" oneditcommand="DL_Items_EditCommand"
oncancelcommand="DL_Items_CancelCommand"
onupdatecommand="DL_Items_UpdateCommand"
onitemcommand="DL_Items_ItemCommand"
onitemdatabound="DL_Items_ItemDataBound"
ondeletecommand="DL_Items_DeleteCommand" RepeatLayout="Flow">
<ItemTemplate>
I've tried looking around google for better solutions to this and all I could find was a way to generate the code in a table which i do not want. Is there a reason why the above code is generating line breaks, <br>
Compete itemtemplate
<ItemTemplate>
<div class="EC_Item_Left_Panel">
<ul class="EC_Item_Left_UL">
<li>
<asp:Image ID="IM_PIC" runat="server" ImageUrl='<%# Eval("path") %>' /></li>
<li>
<asp:LinkButton ID="BT_Edit" CssClass="ecom_edit_tbn" CommandName="Edit" runat="server">Edit Item</asp:LinkButton></li>
<li class="deleteRow">
<asp:LinkButton ID="BT_Delete" ToolTip='<%# Eval("ProductName") %>' runat="server" CssClass="deleteButton ecom_remove_tbn" Text="Delete" ForeColor="Red"></asp:LinkButton>
<asp:Button ID="deleteCommand" runat="server" CausesValidation="false" CommandName="Delete" CssClass="deleteCommand" style="display:none" />
</li>
<%--<asp:LinkButton CssClass="ecom_remove_tbn" ID="BT_Remove" CommandName="Delete" runat="server">Remove</asp:LinkButton>--%>
<li><asp:LinkButton CssClass="ecom_link_tbn" ID="BT_Link" runat="server" CommandName="linkproduct">Linked Items</asp:LinkButton></li>
</ul>
</div>
<div>
<div class="Item_Right_Panel">
<ul class="EC_Item_Top_UL">
<li><label>ProductID </label><span><%#Eval("ProductID")%></span></li>
<li><label>Enabled </label><span><%#Eval("Enabled")%></span></li>
<li><label>Title </label><asp:Label ID="LB_ProductTitle" runat="server" Text='<%#Eval("ProductName")%>'></asp:Label></li>
<li><label>Product Code </label><span><%#Eval("ProductCode")%></span></li>
<li><label>Category </label><span><%#Eval("Category")%></span></li>
<%--Callum--%>
<li><label>Price</label><span><%#Eval("Sale_Price")%></span></li>
<li><label>Subcategory</label><span><%#Eval("Subcat")%></span></li>
<li><label>Designer</label><span><%#Eval("DesignerName")%></span></li>
<li><label>Range</label><span><%#Eval("Range")%></span></li>
<li><label>Height</label></li>
<li><label>Length</label></li>
<li><label>Width</label></li>
<li><label>Description </label><span><%#Eval("Description")%></span></li>
</ul>
<ul class="EC_Item_Bottom_UL">
<li><label>KeyFieldName </label><span><%#Eval("KeyFieldName")%></span></li>
<li><label>ItemField1Name </label><span><%#Eval("ItemField1Name")%></span></li>
<li><label>ItemField2Name </label><span><%#Eval("ItemField2Name")%></span></li>
<li><label>ItemField3Name </label><span><%#Eval("ItemField3Name")%></span></li>
<li><label>ItemField3Name </label><span><%#Eval("ItemField3Name")%></span></li>
<li><label>Include File </label><span> <%# IncludeTitle(DataBinder.Eval(Container.DataItem, "include"))%> </span></li>
</ul>
</div>
</div>
</ItemTemplate>
The DataList creates the br's(See documentation of Flow layout at http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.repeatlayout%28v=VS.100%29.aspx).
If you don't want br's or any extra markup between elements, I'd suggest you to use a Repeater instead.

Categories

Resources