I'm trying to use a simple table nested in a cell to show a graph on my elections result page.
<td>
<%: result.candidateName %>
<table style="border:0; padding:2px;">
<tr>
<td style="width:50px; border:0; height:15px; color:Blue; padding:0; font-size:75%;"><%: result.percentWon %>%</td>
<td style="background-color:Blue; width:400px; border:0; height:15px;"></td>
</tr>
</table>
</td>
What I need to do is change the width figure in the cell style (set to 400px now) to be 4*result.percentWon, but I cant figure out how to put Aligator tags in the middle of the style string.
Yes I'm a noob (o: Can anyone school me?
You can put <%: ... %> where-ever you want:
<td style="background-color:Blue; width:<%:4*result.percentWon%>px; border:0; height:15px;"></td>
Related
I use visual studio 2010 with framework2.0
I design a page use c# ,now ,just called A.aspx.
the page have a table to layout,
like
<table> <tr>
<td>
Name
</td>
<td>
<asp:TextBox .../>
<div id="div1" style="vertical-align: bottom;">
<img.. />
</div>
<div><img ../></div>
<asp:Label .../>
<asp:Label .../>
</td>
</tr>
</table>
Now ,I want to let second<td></td> layout one row. how to set up?
I try <td style ="float:left"> but not worked,it always show two row.
can somebody help me with this?
First understand your layout, here is an example with borders
If you want to float elements try a layout using div and css
A layout with tables is very hard to work with and nobody is doing it anymore. You can use tables for specific situation only if you like but most of the time try to use div layout and the other elements to organize content.
HTML
<table class="borde">
<tr class="borde">
<td class="borde">
Name
</td>
<td class="borde">
fffff
<div class="divRojo"></div>
fffff
</td>
</tr>
</table>
CSS
.borde { border:1px solid black; }
.divRojo { border:1px solid red; }
With one more row and the div
<table class="borde">
<tr class="borde">
<td class="borde">
Name
</td>
<td class="borde">
fffff
<div class="divRojo"></div>
fffff
</td>
</tr>
<tr>
<td colspan="2">
<div>Content in one column in a new row</div>
</td>
</tr>
</table>
You want your second <td> in one row? So, create another <tr>?
<table>
<tbody>
<tr>
<td>
Name
</td>
</tr>
<tr>
<td>
<textarea></textarea>
</td>
</tr>
</tbody>
</table>
http://jsbin.com/uJenUVOx/1/edit
I have fix this question ,the second <td> use <table> then can solve that question.
I wanna make a list using
This is my code on listOfPeople.aspx:
<table id="listOfPeople" runat="server">
<tr id="rowOfPerson" runat="server">
<td id="person" runat="server">name of a person</td>
</tr>
</table>
I want to repeat the to make a list of people via c#:
<table>
<tr>
<td>Charles Bell</td>
</tr>
<tr>
<td>Jason Mc Allister</td>
</tr>
<tr>
<td>Mathew Anderson</td>
</tr>
</table>
I can see "rowOfPerson" on listOfPerson.aspx.cs but I dont know how to create new rows. Thanks.
Remove the table html in the aspx.
In your aspx.cs, write the entire table (including all the rows you want) so that it get rendered dynamically based on whatever your data source is.
This is just one of many ways, but i believe it is the simplest and quickest way for you to achieve this.
There are various ways...
Put this html in repeater control and assign the datasaource to it
<tr id="rowOfPerson" runat="server">
<td id="person" runat="server">name of a person</td>
</tr>
Use anyother ways like add table with runat server attribute... loop through data in code and add tr for that table for your data...
I have a html structure as below
<tr valign="middle" align="left">
<td> </td>
<td class="table_row"><div align="left"></div></td>
<td class="table_row"><div align="right" class="news_headline_txt"> </div></td>
<td class="table_row"><div align="right">28.02.2013</div></td>
<td class="table_row"><div align="right"><a onClick="window.open('show.php?id=id_9000')" href="javascript:;"></a></div></td>
<td> </td>
</tr>
I can get onclick value as below
"//a[contains(#onclick, 'id_')]/#href
but when i get the onclick value, i want match tr's third td values <td class="table_row"><div align="right">28.02.2013</div></td>contains 02.03
Thanks in advance
So you want to find a TR that has a td with a certain position, and then find the anchor within that:
//tr[td[position()=4][contains(text(), '02.03')]]//a[contains(#onclick, 'id_')]/#href
You could also use the sibling axis:
//td[position()=4][contains(text(), '02.03')]/following-sibling:td//a[contains(#onclick, 'id_')]/#href
Note the position check is for the 4th td, since there is a blank padding td at the beginning of the row.
I realize this is a strange/simple question. I have HTML—tables and rows—that make up a grid. I need the resulting grid to look exactly like the HTML does, with data pulled from a DataTable.
How should I go about doing that? If I replace the HTML with a GridView the result will look different from what I need it to look like. Do I create a custom grid class that spits out tables and rows?
To clarify: I've been given an HTML grid...
<div>
<table>
<tr>
<td>row 1 col 1</td>
<td>row 1 col 2</td>
</tr>
<tr>
<td>row 2 col 1</td>
<td>row 2 col 2</td>
</tr>
</table>
</div>
...which I now need to populate with data from a table, and preserve the original HTML.
If you want to use ASP.Net databinding capabilities, go with a Repeater. The markup will look something like this:
<table>
<thead>
<tr>
<th>Heading</th>
</tr>
</thead>
<tbody>
<asp:Repeater runat="server">
<ItemTemplate>
<tr>
<td><%# Eval("SomeFieldName") %></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</tbody>
</table>
You can also build the markup manually in the code-behind by instantiating table/row/cell objects and adding them to the controls collection of the page, control, or parent container control. This tends to be time-consuming but it's a valid option in some cases, such as when you wish to have highly dynamic content that isn't easy to express in a Repeater.
A third option is to mix server markup with client markup, e.g.
<table>
<thead>
<tr>
<th>Heading</th>
</tr>
</thead>
<tbody>
<% foreach( var obj in someCollection ){ %>
<tr>
<td><%= obj.Property %></td>
</tr>
<% } %>
</tbody>
</table>
The last option is quite similar (albeit more verbose) to Razor syntax used in ASP.Net MVC views.
I think your best bet for that would be a repeater. Link below.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.repeater(v=vs.100).aspx
Another option would be to use a ListView with your HTML table setup as the LayoutTemplate.
quick example:
<asp:ListView ID="MyListView" runat="server">
<LayoutTemplate>
<table id="Table1" cellpadding="1" width="100%" runat="server">
<tr id="Tr1" runat="server">
<th id="Th1" style="font-weight: bold; text-align: left" runat="server">
Header1
</th>
<th id="Th2" style="font-weight: bold; text-align: left" runat="server">
Header2
</th>
</tr>
<tr runat="server" id="itemPlaceholder" />
</table>
</LayoutTemplate>
<ItemTemplate>
<tr id="Tr2" runat="server">
<td style="text-align: left">
<%# Eval("Field1")%>
</td>
<td style="text-align: left">
<%# Eval("Field2")%>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
Here i am a dragging a table(1) row and dropping it in another table(2) using asp.net mvc similar to this one http://www.redips.net/javascript/drag-and-drop-table-row/ and the values are from database .It is working fine and what i need is the html table values (i.e the values inside the td) of the table(2).how can i get those values and save it in dataset in asp.net MVC.Here is my code
<div id="drag">
<table class="tbl1">
<tr>
<th colspan="2">
Table 1
</th>
</tr>
<% foreach (var item1 in Model)
{ %>
<tr class="rl">
<td class="rowhandler">
<div class="drag row">
<%= Html.Encode(item1.Id) %>
</div>
</td>
<td class="rowhandler">
<div class="drag row">
<%= Html.Encode(item1.Title) %>
</div>
</td>
</tr>
<% } %>
<tr style="display: none;">
<td colspan="2">
<span>Message line</span>
</td>
</tr>
</table>
<table id="tab" runat="server">
<tr>
<th colspan="2" class="mark">
Table 2
</th>
</tr>
<tr class="rd">
<td>
</td>
<td>
</td>
</tr>
<tr style="display: none;">
<td colspan="2">
<span>Message line</span>
</td>
</tr>
</table>
</div>
Any suggesion?I am new to MVC
Use jQuery ajax to save the data in server. You can make a call to a controller action from your jquery with your data and it can save the data to your tables.
var mydata=""; /// read your table cells values and store it in this string
$.post("yourcontroller/action/", { data : mydata} ,function(response){
//do something with the response from action
});
As Brian already suggested, traversing the DOM maybe a bad idea. A better way would be to store the table2 data in a javascript array (whenever a drop event occurs add to the array, or remove from the array when cells are dragged off the table). Then have an ajax call to submit the whole array in one go.
If I am understanding this correctly when the page loads you have the data for both tables in the database. You can just keep a working set of the changes being made to the table and update those records accordingly. Add logic to the "drop" event in your JS to store the item's ID and it's new position.
This saves you from having to update unaffected records and also from traversing the entirety of both tables on submit.