how to use css align control one row - c#

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.

Related

How to debug an aspx page, keeps saying page not found when there is an error

I have a page with a listview and there is some problem with it, however instead of getting an error, when I run it I get a 404 resource not found error. If I remove the offending listview and run then it runs fine, so it is not an issue with it not looking in the right place for the page etc.
How can I find out what the error is with the listview, at the moment I'm getting no information about it, it even renders correctly in design view.
Many thanks
For info the code is below, however I need to know how to debug it as this has happened lots of times before.
If I remove this listview the page works..
<asp:ListView ID="lvPerformanceKPIs" runat="server"
OnItemDataBound="lvPerformanceKPIs_ItemDataBound" DataKeyNames="PerformanceMeasureID"
OnItemCommand="lvPerformanceKPIs_ItemCommand" ItemPlaceholderID="itemPlaceholder"
>
<LayoutTemplate>
<table width="100%" border="0" cellpadding="2" cellspacing="0">
<tr>
<th width="5%" class="Actions" >
Actions
</th>
<th width="2%" >&nbsp
</th>
<th width="5%">
ID
</th>
<th width="28%">
Group
</th>
<th width="40%">
Indicator
</th>
<th width="20%">
Threshold
</th>
</tr>
</table>
<div runat="server" id="itemPlaceHolder">
</div>
</LayoutTemplate>
<ItemTemplate>
<div id="Div1" class="SUBDIV" runat="server">
<table width="100%" border="0" cellpadding="2" cellspacing="0">
<tr>
<td width="5%" class="Actions">
<%--<img id="btnEdit" style="cursor: pointer;" alt="Edit" title="Edit this record" src="images/edit.png" width="15px"
onclick="CRMEdit(this);"/>
<asp:ImageButton ID="btnDelete" runat="server" title="Delete this record" src="images/delete.png" width="15px"
OnclientClick="return confirm('Are you sure you want to delete this record?')"
CommandName="cmdDelete" CommandArgument=<%#Eval("PerformanceMeasureID") %> /> --%>
</td>
<td width="2%">
<div class="btncolexp collapse" title="Expand to reveal/add files">
</div>
</td>
<!-- id columns to get values then will be hidden with jquery -->
<td class="hidCol">
<span id="itemServiceSpecID"><%#Eval("ServiceSpecID")%></span>
</td>
<td class="hidCol">
<span id="itemPerfSortOrder"><%#Eval("PerfSortOrder")%></span>
</td>
<td class="hidCol">
<span id="itemPerfType"><%#Eval("PerfType")%></span>
</td>
<td class="hidCol">
<span id="itemPerfFrequency"><%#Eval("PerfFrequency")%></span>
</td>
<td width="5%">
<span id="itemPerformanceMeasureID"><%#Eval("PerformanceMeasureID")%></span>&nbsp
</td>
<td width="28%">
<span id="itemPerfGroup"><%#Eval("PerfGroup")%></span>&nbsp
</td>
<td width="40%">
<span id="itemPerfMeasure"><%#Eval("PerfMeasure")%></span>&nbsp
</td>
<td width="20%">
<span id="itemPerfThresholdText"><%#Eval("PerfThresholdText")%></span>&nbsp
</td>
</tr>
</table>
</div>
</ItemTemplate>
</asp:ListView>
i wonder if those images are properly commented-out in the item template. make sure there is no conflict between the comment tags (<%-- --%>) and the data binding tags.
also, the CommandArgument needs to be quoted:
CommandArgument='<%#Eval("PerformanceMeasureID") %>'

How to set accessibility attributes within .NET 's MenuItems, _without_ JavaScript

I am working on a sidenav that is built on .NET MenuItems like so:
<asp:MenuItem value="19" Text="Profile" Selectable="false"></asp:MenuItem>
<asp:MenuItem value="0" Text="Overview" ToolTip="Overview" Selected="true"></asp:MenuItem>
<asp:MenuItem value="2" Text="My Info & Email Subscriptions" ToolTip="My Info & Email Subscriptions"></asp:MenuItem>
In HTML, the output produces a series of nested tables around each MenuItem which looks like this:
<div id="_links" class="span-3">
<table id="FormUserControl__tabMenu" cellpadding="0" cellspacing="0" border="0" style="clear:left;">
<tbody>
<tr id="FormUserControl__tabMenun0">
<td>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tbody>
<tr>
<td style="white-space:nowrap;width:100%;">
<a style="text-decoration:none;">
<div id="FormUserControl__tabMenu_ctl00__tabMenuItemPanel" class="myAccountHeading ">
Profile
</div>
</a>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr onmouseover="Menu_HoverStatic(this)" onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)" title="Overview" id="FormUserControl__tabMenun1">
<td>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tbody>
<tr>
<td style="white-space:nowrap;width:100%;"><a href="javascript:__doPostBack('FormUserControl$_tabMenu','0')" style="text-decoration:none;">
<div id="FormUserControl__tabMenu_ctl01__tabMenuItemPanel" class="sideNav">
Overview
</div>
</td>
<tr>
<tbody>
</td>
</tr>
</tbody>
</table>
</div>
How can I add to add accessibility role and aria-level to these innermost divs? The goal is to achieve accessibility compliance. For example:
<div role="heading" aria-level="[2]">Profile</div>
I have looked through MSDN documentation and it looks like there isn't a way to add those attributes within the intial MenuItem declaration.
I also tried adding role and aria-level attributes within CSS, which I know is hacky, but I figured since content can be set, it was worth trying. That doesn't work.
I could readily do this in JavaScript, but I really want to avoid involving that, it's a last resort and I do know how to do that.
Is there a way to change the MenuItem output to involve role and aria-level? Or, is there a way to have it output a header instead of a div nested within two tables?
Many thanks!

How to create Regexp for html page

I have html page with this code
<table class="data">
<tr>
<td class="head" >Time</td>
<td class="head right" >Pref</td>
<td class="head" >Name</td>
<td class="head">Descr</td>
</tr>
<tr>
<td colspan="4" class="date">
2014.03.17
</td>
</tr>
<tr valign="top" class="dat">
<td>22:02</td>
<td class="right">
3/2014
</td>
<td>
<a href="/reports/id=34">
<b>Company Name</b>
</a>
</td>
<td>
<a href=/reports/view/id=34" target="_blank" class="th">
Description
</a>
</td>
</tr>
<tr valign="top" class="date">
<td>21:16</td>
<td class="right">
8/2014
</td>
<td>
<a href="/reports/id=324">
<b>Company Name2</b>
</a>
</td>
<td>
<a href="reports/view/=324" target="_blank" class="th">
Description
</a>
</td>
</tr>
................................
</table>
Can you help me create regexp to extract data from table. I need this data 21:16,8/2014,Company Name2,Description
Thanks.
Do NOT try parsing HTML with Regex. You might get fairly far, but it's very easy to screw it up and it doesn't work well. It learned this the hard way once. Like others have mentioned in the comments. See:
https://stackoverflow.com/a/1732454/794380
You should try the Html Agility pack: http://htmlagilitypack.codeplex.com
Take a look here https://stackoverflow.com/a/19871589/307976

Xpath also parent child contains spesific value

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.

Retrofit plain HTML grid to c# grid

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>

Categories