Multilingual pages and dynamic multilingual content - c#

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

Related

Certain controls won't get generated in aspx.designer.cs-file

I have a weird problem. I can't access some of my server controls from my codebehind. I've looked around and can only find answers for situations where you can't find ANY controls and I've tried all solutions I've found here on stack. re-creating designer file, deleting temp data, renaming controls etc. Nothing works.
The weird thing is that I can access every controller I put outside my ListView element. But everything inside will not get generated in my aspx.designer.cs file.
Code:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolderMid" runat="server">
<h2><asp:Label ID="LabelCat" runat="server" Text=""></asp:Label></h2>
<asp:HiddenField ID="HiddenFieldID" runat="server" />
<br />
<div class="list-group">
<asp:ListView ID="ListViewSearch" runat="server" DataSourceID="SqlDataSourceWebsite" DataKeyNames="WebsiteID">
<EmptyDataTemplate>
<table runat="server">
<tr>
<td>Darn</td>
</tr>
</table>
</EmptyDataTemplate>
<ItemTemplate>
<td>
<div class="row list-group-item">
<div class="">
<%# Eval("url") %>
</div>
<div class="col-xs-5">
<div class="pull-left">
<div>
<asp:LinkButton ID="BtnUp" runat="server" CssClass="btn btn-default btn-xs" CommandArgument='<%# Eval("websiteId").ToString() %>' OnClick="up_click"><i class="fa fa-chevron-up" style="color:green"></i></asp:LinkButton>
</div>
<div>
<asp:LinkButton ID="BtnDown" runat="server" CssClass="btn btn-default btn-xs" CommandArgument='<%# Eval("websiteId").ToString() %>' OnCommand="down_click"><i class="fa fa-chevron-down" style="color:red"></i></asp:LinkButton>
</div>
</div>
<div class="lbl-score">
<asp:Label ID="LabelScore" runat="server" Text="Score: "></asp:Label>
<asp:ScriptManagerProxy ID="ScriptManagerProxySearch" runat="server"></asp:ScriptManagerProxy>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Label ID="LabelRating" runat="server" Text=' <%# Eval("rating") %>'></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="BtnUp" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</div>
</div>
<div class="lbl-desc">
<asp:Label ID="LabelDesc1" runat="server" Text=' <%# Eval("Description1") + " | "%> '></asp:Label>
<asp:Label ID="LabelDesc2" runat="server" Text=' <%# Eval("Description2") %> '></asp:Label>
</div>
</div>
</td>
</ItemTemplate>
</asp:ListView>
</div>
<asp:SqlDataSource ID="SqlDataSourceWebsite" runat="server" ConnectionString="<%$ ConnectionStrings:WDBAPPConnectionString %>" SelectCommand="SELECT * FROM [Website] WHERE ([categoryId] = #HFID)">
<SelectParameters>
<asp:ControlParameter ControlID="HiddenFieldID" Name="HFID" Type="Int32" DefaultValue="0" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Content>
I know there is a lot of code but basically the controls "LabeCat", "HiddenFieldID", "ListViewSearch" and "SqlDataSourceWebsite" show up in my aspx.designer.cs-file, but no other controls do, in other words; all controls before and after my ListView work fine. What could be wrong here? So confused.

How to use radio button with dynamic list view?

I am trying to make an online test system, where questions and options are added from database to list view. plz tell me how can i use radio button to check if question was correct or not.
this is the code i am using:-
<asp:listview ID="Listview1" runat="server">
<LayoutTemplate>
<ul class="row" style="list-style:none;">
<asp:PlaceHolder ID="itemPlaceholder" runat="server">
</asp:PlaceHolder>
</ul>
</LayoutTemplate>
<ItemTemplate>
<li>
<div class="row1">
Q. <%#Eval("question") %>><br />
<asp:RadioButton ID="RadioButton1 runat="server" /><%#Eval("op1") %>>
<br />
<asp:RadioButton ID="RadioButton2" runat="server" /><%#Eval("op2") %>>
<br />
<asp:RadioButton ID="RadioButton3" runat="server" /><%#Eval("op3") %>>
<br />
<asp:RadioButton ID="RadioButton4" runat="server" /><%#Eval("op4") %>>
</div>
</li>
</ItemTemplate>
</asp:listview>
Since you are loading the options dinamically, you have to get the values using Request["RadioButton1"] for example, after the postback

Creating Bootstrap-Datepicker with multiple asp:Repeater TextBoxes

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();

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.

ListView Coding

How do i code the "View Details" portion of my ListView to hyperlink it to the product details page? My product catalog is displayed as follows:
ListView codes
<asp:ListView runat="server" ID="listView" GroupItemCount="3"
DataSourceID="AccessDataSource1">
<LayoutTemplate>
<div style="height: 966px;">
<div style="width: 771px;">
<asp:PlaceHolder runat="server" ID="groupPlaceHolder" />
<asp:DataPager runat="server" ID="dpMyDatePager" PageSize="9"
PagedControlID="listView">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True"
ShowFirstPageButton="True" />
<asp:NumericPagerField />
</Fields>
</asp:DataPager>
</div>
</LayoutTemplate>
<GroupTemplate>
<div style="clear: both;">
<asp:PlaceHolder runat="server" ID="itemPlaceHolder" />
</div>
</GroupTemplate>
<ItemTemplate>
<div class="productItem">
<div>
<img src='<%# Eval("ProductUrl") %>' >
</div>
<div class="catalog-price">
<br />
<%# Eval("ProductBrand") %>
<%# Eval("ProductModel") %></div>
<div class="catalog-price2">
<b>
Our Price: S$<%# Eval("NormalPrice") %></div>
</b><br />
<div class="cell1">
Add to cart</div>
<div class="cell2">
View details</div>
</div>
</ItemTemplate>
You have to pass the id of Selected Product to view the details of Selected Product.
Your ViewDetails button code should be like...
<asp:HyperLink ID="HypViewDetails" ImageUrl="~/Images/viewDetails.png"
NavigateUrl='<%#Eval("ProductId", "ProductDetails.aspx?cid={0}")%>'
runat="server"></asp:HyperLink>
Put the view details div in a hyperlink, coded with the model id?

Categories

Resources