How i enable div from code behind in ontick event? - c#

.aspx page
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick" >
</asp:Timer>
<br />
<br />
<table style="position: absolute; top: 600px; left: 167px; width: 1010px; height: 124px;">
<tr>
<td><asp:Label ID="Label13" runat="server"></asp:Label></td>
<td >DAYS</td>
<td><asp:Label ID="Label14" runat="server"></asp:Label></div></td>
<td > HOURS</td>
<td><asp:Label ID="Label15" runat="server"></asp:Label></td>
<td >MIN</td>
<td><asp:Label ID="Label16" runat="server"></asp:Label></td>
<td > SEC</td>
<td><asp:Label ID="Label17" Text="=Remaining For Vote Day" runat="server" ></asp:Label></td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div id="theDiv1" runat="server" style="height: 182px;display:none">
<table align="center" class="auto-style1" style="border-style: dashed; border-color: #008000; height: 179px; width: 366px; margin-left: 300px;">
<tr>
<td class="auto-style2"> </td>
<td>
<asp:Label ID="Label1" runat="server" Font-Bold="true" Font-Size="X-Large" Text="Voter login"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label2" runat="server" Text="Name"> </asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server" Width="177px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label3" runat="server" Text="Password"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server" TextMode="Password" Width="179px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2"> </td>
<td>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Log in" Width="65px" />
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">New User</asp:LinkButton>
</td>
</tr>
<tr>
<td class="auto-style2"> </td>
<td>
<asp:LinkButton ID="LinkButton2" runat="server" OnClick="LinkButton2_Click">Forgot Password</asp:LinkButton>
</td>
</tr>
</table>
<asp:Label ID="label4" runat="server"></asp:Label>
</div>
</Content>
.aspx.cs page
protected void Timer1_Tick(object sender, EventArgs e)
{
DateTime dt = DateTime.Now;
TimeSpan differ;
System.DateTime date1 = new System.DateTime(2015, 4, 1, 20, 10, 0);
differ = date1.Subtract(dt);
double t = differ.TotalSeconds;
if (t > 0)
{
double dy, h, m, s;
dy = differ.Days;
h = differ.Hours;
m = differ.Minutes;
s = differ.Seconds;
Label13.Text = dy.ToString();// +" Days " + h + " Hours " + m + " Minutes " + s + " Seconds left for celebration";
Label14.Text = h.ToString();
Label15.Text = m.ToString();
Label16.Text = s.ToString();
}
else
{
Timer1.Enabled = false;
time_enable.Visible = false;
theDiv1.Visible = true;
}
}
After writing theDiv1.Visible = true; this statement theDiv1 is not visible and don't work.
How can I solve it?

You have set display=none in style property and making Visible=true on server side which doesn't make sense!! so you need to do it as below
theDiv1.Style.Remove("display");//To be on safer side do this first
theDiv1.Style.Add("display","block");
or
theDiv1.Style.Add(HtmlTextWriterStyle.Display, "block");
Alternative
If you make change to your div as below
<div id="theDiv1" Visible="false" runat="server" style="height: 182px;">
then whatever code you have written will work for sure.

Related

Listview With Data Pager Control Sort Error

I have a listview that I bind using custom code in the code behind. The listview has a datapager and needs to be sorted.
I created a custom sort routine that successfully sorts the list view. The issue is that if I change the page using the datapager, the sort is not maintained (i.e. page 2 and up are not sorted)
Here is the code for the list view:
<asp:ListView ID="lv_positions_i_posted" runat="server" DataKeyNames="postingid" OnPagePropertiesChanging="lv_positions_i_posted_paging" OnItemDataBound="lv_positions_i_posted_ItemDataBound">
<LayoutTemplate>
<table id="Table2" runat="server">
<tr id="Tr1" runat="server">
<td id="Td1" runat="server">
<table id="itemPlaceholderContainer" runat="server" border="1"
style="border-collapse: collapse; border-color: #999999; border-style: none; border-width: 1px; font-family: Verdana, Arial, Helvetica, sans-serif;">
<tr>
<th colspan="2" style="background-color: darkseagreen;">Posting </th>
<th colspan="1" style="background-color: sandybrown;">Applications </th>
<th colspan="4">Positions I Posted </th>
</tr>
<tr id="Tr2" runat="server" style="color: #000000;">
<th id="Th1" runat="server" style="background-color: darkseagreen;">View </th>
<th id="Th2" runat="server" style="background-color: darkseagreen;">Edit </th>
<th id="Th3" runat="server" style="background-color: sandybrown;">View </th>
<th id="Th4" runat="server">ID </th>
<th id="Th6" runat="server">Title </th>
<th id="Th8" runat="server">Posting Date
<asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="conditional">
<ContentTemplate>
<asp:ImageButton ID="SortPostingButton" runat="server" ImageUrl="~/images/Up2.png" Height="20px" Width="20px" ToolTip="Sort" OnClick="PostingSort1_Click" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="SortPostingButton" />
</Triggers>
</asp:UpdatePanel>
</th>
<th id="Th9" runat="server">Status
<asp:ImageButton ID="SortStatusButton" runat="server" ImageUrl="~/images/Up2.png" Height="20px" Width="20px" ToolTip="Sort" OnClick="StatusSort1_Click" />
</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr id="Tr3" runat="server">
<td id="Td2" runat="server"
style="text-align: center; background-color: #CCCCCC; font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000;">
<asp:DataPager ID="DataPager1" runat="server" PagedControlID="lv_positions_i_posted" PageSize="20">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True"
ShowNextPageButton="False" ShowPreviousPageButton="False" />
<asp:NumericPagerField ButtonCount="10" />
<asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True"
ShowNextPageButton="False" ShowPreviousPageButton="False" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr style="background-color: #DCDCDC; color: #000000; font-weight: normal;">
<td style="text-align: center">
<asp:ImageButton ID="ViewPostingButton" runat="server" ToolTip="View Posting" ImageUrl="~/images/green-eye-icon-new-small.png" Width="30px" Height="18.75px" OnCommand="ViewPostingButton_Click" CommandArgument=' <%#Eval("PostingID")%>' />
</td>
<td style="text-align: center">
<asp:ImageButton ID="EditPostingButton" runat="server" ToolTip="Edit Posting" ImageUrl="~/images/pencil_small.png" Width="18.75px" Height="18.75px" OnCommand="EditPostingButton_Click" CommandArgument=' <%#Eval("PostingID")%>' />
</td>
<td style="text-align: center">
<asp:ImageButton ID="ViewPostingApplicantButton" runat="server" ToolTip="View Applicants" ImageUrl="~/images/green-eye-icon-new-small.png" Width="30px" Height="18.75px" ImageAlign="Middle" OnCommand="ViewPostingApplicantButton_Click" CommandArgument=' <%#Eval("PostingID")%>' />
</td>
<td style="text-align: center">
<asp:Label ID="PostingID" runat="server" Text=' <%# Eval("PostingID") %>' Visible="true" />
</td>
<td>
<asp:Label ID="PostingTitle" runat="server" Text=' <%# Eval("PostingTitle") %>' Visible="true" ToolTip=' <%# Eval("PostingTitleFull") %>' />
</td>
<td style="text-align: center">
<asp:Label ID="PostingDate" runat="server" Text=' <%# Eval("PostingDate","{0:MM/dd/yyyy}") %>' Visible="true" />
</td>
<td style="text-align: center">
<asp:Label ID="PostingStatusID" runat="server" Text=' <%# Eval("PostingStatusID") %>' Visible="true" />
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr style="background-color: #FFF8DC; color: #000000; font-weight: normal;">
<td style="text-align: center">
<asp:ImageButton ID="ViewPostingButton" runat="server" ToolTip="View Posting" ImageUrl="~/images/green-eye-icon-new-small.png" Width="30px" Height="18.75px" OnCommand="ViewPostingButton_Click" CommandArgument=' <%#Eval("PostingID")%>' />
</td>
<td style="text-align: center">
<asp:ImageButton ID="EditPostingButton" runat="server" ToolTip="Edit Posting" ImageUrl="~/images/pencil_small.png" Width="18.75px" Height="18.75px" OnCommand="EditPostingButton_Click" CommandArgument=' <%#Eval("PostingID")%>' />
</td>
<td style="text-align: center">
<asp:ImageButton ID="ViewPostingApplicantButton" ToolTip="View Applicants" runat="server" ImageUrl="~/images/green-eye-icon-new-small.png" Width="30px" Height="18.75px" ImageAlign="Middle" OnCommand="ViewPostingApplicantButton_Click" CommandArgument=' <%#Eval("PostingID")%>' />
</td>
<td style="text-align: center">
<asp:Label ID="PostingID" runat="server" Text=' <%# Eval("PostingID") %>' Visible="true" />
</td>
<td>
<asp:Label ID="PostingTitle" runat="server" Text=' <%# Eval("PostingTitle") %>' Visible="true" ToolTip=' <%# Eval("PostingTitleFull") %>' />
</td>
<td style="text-align: center">
<asp:Label ID="PostingDate" runat="server" Text=' <%# Eval("PostingDate","{0:MM/dd/yyyy}") %>' Visible="true" />
</td>
<td style="text-align: center">
<asp:Label ID="PostingStatusID" runat="server" Text=' <%# Eval("PostingStatusID") %>' Visible="true" />
</td>
</tr>
</AlternatingItemTemplate>
<EmptyDataTemplate>
<table id="Table1" runat="server"
style="background-color: #FFFFFF; border-collapse: collapse; border-color: #999999; border-style: none; border-width: 1px;">
<tr>
<td>No data was returned. </td>
</tr>
</table>
</EmptyDataTemplate>
</asp:ListView>
Here is where I capture the sort:
protected void PostingSort1_Click(object sender, ImageClickEventArgs e)
{
if (TheListView.Text == "1")
{
if (LastSortField.Text == "p.postingdate")
{
if (LastSortDirection.Text == "asc")
{
ImageButton button = (ImageButton)sender;
button.ImageUrl = "~/images/Down2.png";
}
else
{
ImageButton button = (ImageButton)sender;
button.ImageUrl = "~/images/Up2.png";
}
}
}
currentLV = TheListView.Text;
BindListview(currentLV, "p.postingdate");
}
Here is where I bind/re-bind the listview:
protected void BindListview(string selectedItem, string orderby)
{
string SQL = "";
string direction = "";
SQL = "Select Statment Here";
if (orderby != "")
{
if (selectedItem == TheListView.Text)
{
if (orderby == LastSortField.Text)
{
if (LastSortDirection.Text == "asc")
{
direction = "desc";
}
else
{
direction = "asc";
}
SQL += " Order by " + orderby + " " + direction;
LastSortDirection.Text = direction;
LastSortField.Text = orderby;
}
else
{
SQL += " Order by " + orderby;
LastSortDirection.Text = "asc";
LastSortField.Text = orderby;
}
}
else
{
SQL += " Order by '" + orderby ;
LastSortDirection.Text = "asc";
LastSortField.Text = orderby;
}
}
else
{
SQL += " Order by PostingID asc";
LastSortDirection.Text = "asc";
LastSortField.Text = "PostingID";
}
DataSet ds = jdh.GetDataSetFromDB(SQL);
lv_positions_i_posted.DataSource = ds;
lv_positions_i_posted.DataBind();
lv_positions_i_posted.Visible = true;
ds.Dispose();
}
As I indicated, the displayed listview data is sorted correctly EXCEPT it is not being maintained when I use the datapager. I am expecting that the entire listview is sorted correctly throughout the paged data.
I figured it out. I forgot that I captured the datapager page change and was not passing in the "orderby" variable. Once I fixed that it works correctly.
protected void lv_positions_i_manage_paging(object sender, PagePropertiesChangingEventArgs e)
{
(lv_positions_i_manage.FindControl("DataPager1") as DataPager).SetPageProperties(e.StartRowIndex, e.MaximumRows, false);
if (LastSortDirection.Text == "asc")
{
LastSortDirection.Text = "desc";
}
else
{
LastSortDirection.Text = "asc";
}
BindListview("2", LastSortField.Text);
}

Change table row text and bgcolor on a listview value asp.net C

I have a listview and I am trying to change the text color and background color depending on the value of "callswaiting". This is written in C#.
I am trying to accomplish this:
If(Eval("availableAgents") < 1); Then
; If(Eval("callsWaiting" > 2) ,Then );
{
tblSheet.Style.Add("color", "black");
tblSheet.Style.Add("background-color", "red");
}
Else;
{
tblSheet.Style.Add("color", "black");
tblSheet.Style.Add("background-color", "orange");
}
End If;
Else;
{
tblSheet.Style.Add("color", "white");
tblSheet.Style.Add("background-color", "green");
}
End If;
Just stumped on how to update this to ASPX and C#.
My ASPX code is:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
<asp:ListView ID="ListView1" runat="server" DataSourceID="con_csq_agentDB" onitemdatabound="ListView1_ItemDataBound">
<AlternatingItemTemplate>
<tr id="MainTableRow" style="background-color: #ADADAD;">
<td style="background-color: gray; color: whitesmoke;">
<asp:Label ID="csqnameLabel" runat="server" Text='<%# Eval("csqname") %>' />
</td>
<td>
<asp:Label ID="callswaitingLabel" runat="server" Text='<%# Eval("callswaiting") %>' />
</td>
<td>
<asp:Label ID="convoldestcontactLabel" runat="server" Text='<%# Eval("convoldestcontact") %>' />
</td>
<td>
<asp:Label ID="loggedinagentsLabel" runat="server" Text='<%# Eval("loggedinagents") %>' />
</td>
<td>
<asp:Label ID="availableagentsLabel" runat="server" Text='<%# Eval("availableagents") %>' />
</td>
<td>
<asp:Label ID="talkingagentsLabel" runat="server" Text='<%# Eval("talkingagents") %>' />
</td>
</tr>
</AlternatingItemTemplate>
<ItemTemplate>
<tr id="MainTableRow" style="background-color: #DCDCDC; color: #000000;">
<td style="background-color: gray; color: whitesmoke;">
<asp:Label ID="csqnameLabel" runat="server" Text='<%# Eval("csqname") %>' />
</td>
<td>
<asp:Label ID="callswaitingLabel" runat="server" Text='<%# Eval("callswaiting") %>' />
</td>
<td>
<asp:Label ID="convoldestcontactLabel" runat="server" Text='<%# Eval("convoldestcontact") %>' />
</td>
<td>
<asp:Label ID="loggedinagentsLabel" runat="server" Text='<%# Eval("loggedinagents") %>' />
</td>
<td>
<asp:Label ID="availableagentsLabel" runat="server" Text='<%# Eval("availableagents") %>' />
</td>
<td>
<asp:Label ID="talkingagentsLabel" runat="server" Text='<%# Eval("talkingagents") %>' />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table id="itemPlaceholderContainer" runat="server" data-height='100%'>
<tr runat="server" style="background-color: #113C77; color: #000000;">
<th runat="server"></th>
<th runat="server">Calls waiting</th>
<th runat="server">Current Wait</th>
<th runat="server">Agents Logged in</th>
<th runat="server">Ready</th>
<th runat="server">Talking</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
My C# code is:
public partial class csq_agent : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ListView1.DataSourceID = con_csq_agentDB.UniqueID;
}
}
protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
{
if (e.Item.ItemType == ListViewItemType.DataItem)
{
ListViewDataItem dataitem = (ListViewDataItem)e.Item;
int callswaiting = (int)DataBinder.Eval(dataitem.DataItem, "callswaiting");
if (callswaiting == 3)
{
HtmlTableRow cell = (HtmlTableRow)e.Item.FindControl("MainTableRow");
cell.BgColor = "Red";
}
}
}

unable to export html table content to excel in asp.net

when the html table is exported to excel from asp.net the table is displayed but the content inside the table is not displayed below is my code.
protected void btnExportToExcel_Click(object sender, EventArgs e)
{
Response.Clear();
Response.Buffer = true;
lblCategorystatusReportHeader.Visible = true;
Response.AddHeader("content-disposition",
"attachment;filename=StatusReport.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
//Panel preOrderPanel = (Panel)rpt1.FindControl("pnlPreOrder");
//rptCP.RenderControl(hw);
//pnlPreOrder.RenderControl(hw);
order.RenderControl(hw);
string output = sw.ToString();
output = "<html><head><meta charset=" + Encoding.UTF8.WebName + " /></head><body>" + output + "</body></html>";
Response.Output.Write(output);
Response.Flush();
Response.End();
lblCategorystatusReportHeader.Visible = false;
}
below is the aspx code
&nbsp
</asp:TableRow>
</asp:Table>
<table>
<tr>
<td>
&nbsp
</td>
</tr>
</table>
<table>
<%-- <tr style="text-align:center">
<td colspan="20" style="font-size:16px; padding-left:100px;background-color:#90cad9;border:1px solid black;display:none">
<b><asp:Label ID="lblCategorystatusReportHeader" runat="server" Text="Category Status Report"></asp:Label></b>
</td>
</tr>--%>
<tr>
<td style="width:150px !important;vertical-align:middle;text-align:center; border-style:solid; border-width:1px" rowspan="2">
<asp:Label ID="lblCPPre" runat="server"></asp:Label>
</td>
<td>
<%-- <asp:Panel ID="pnlPreOrder" runat="server">--%>
<table border="1" style="border-collapse:collapse">
<tr>
<%--<td stylwe="width:40px">
<asp:Label ID="lblCPPre" runat="server"></asp:Label>
</td>--%>
<td style="vertical-align:middle;background-color:#90cad9;text-align:center">
<div style="width:100px !important">Category CP</div>
</td>
<td>
<asp:Label ID="lblMessagePre" runat="server" Text="No Records found" Visible ="false" ForeColor="Red"></asp:Label>
<asp:Repeater ID="rptStylePO" runat="server" OnItemDataBound="rptStylePO_ItemDataBound">
<ItemTemplate>
<table border="1" style="border-collapse:collapse;border-spacing:0px">
<tr>
<td class="stylestatusReport">
<div style="width:100px !important"> <asp:HiddenField ID="styleid" runat="server" Value='<%# Container.DataItem.ToString() %>'/>
<asp:Label ID="lblStyle" runat="server"></asp:Label></div>
</td>
<td>
<asp:Label ID="lblNoMilestonePre" runat="server" Text="No Records found" Visible ="false" ForeColor="Red"></asp:Label>
<asp:Repeater ID="rptt" runat="server" OnItemDataBound="rptt_ItemDataBound">
<ItemTemplate>
<table>
<tr>
<td style="width:60px;vertical-align:middle;text-align:center">
<div style="width:60px !important"><asp:HiddenField ID="stlId" runat="server" Value='<%# Container.DataItem.ToString() %>' /></div>
</td>
<td>
<asp:DataList ID="dataListPO" runat="server" RepeatDirection="Horizontal" OnItemDataBound="dataListPO_ItemDataBound">
<ItemTemplate>
<table border="1" style="border-collapse:collapse; border-spacing:0px" >
<tr>
<td style="word-wrap:break-word;width:110px; height:60px; color:#000000;vertical-align:middle;text-align:center; background-color:#90cad9 ; font-size:11px;">
<div style="word-wrap:break-word;width:100%;font-size:13px">
<asp:Label ID="lblMilestoneValue" runat="server" Text='<%# Eval("MilestoneName") %>'></asp:Label></div>
</td>
</tr>
<tr>
<td style="text-align:left;">
<asp:Table ID="tblStatus" runat="server" Width="100%">
<asp:TableRow ID="rowStatus" runat="server">
<asp:TableCell ID="cellStatus1" Width="25px" runat="server"><div style="width:100px; text-align:justify"><asp:Label ID="lblForecastedDate" Font-Size="13px" runat="server" Width="50%" ForeColor="Black"></asp:Label></div></asp:TableCell>
<asp:TableCell ID="cellStatus" Width="25px" runat="server"> <div style="width:100px; text-align:center">
<asp:Label ID="lblStatus" Font-Size="13px" runat="server" ForeColor="White"></asp:Label></div>
</asp:TableCell>
</asp:TableRow></asp:Table>
<asp:HiddenField ID="hdnPlannedDate" runat="server" Value='<%# Eval("MilestonePlannedDate") %>'></asp:HiddenField>
<asp:HiddenField ID="hdnRevisedDate" runat="server" Value='<%# Eval("MilestoneRevisedDate") %>'></asp:HiddenField>
<asp:HiddenField ID="hdnActualDate" runat="server" Value='<%# Eval("MilestoneActualDate") %>'></asp:HiddenField>
<asp:HiddenField ID="hdnMilestoneStatus" runat="server" Value='<%# Eval("MilestoneStatus") %>' />
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
</td>
</tr>
</table>
<%-- </asp:Panel>--%>
</td>
</tr>
<tr>
<td>
<%-- <asp:Panel ID="pnlPostOrder" runat="server">--%>
<table border="1" style="border-collapse:collapse;">
<tr>
<%--<td style="width:40px">
<asp:Label ID="lblCPPost" runat="server"></asp:Label>
</td>--%>
<td style=" background-color:#90cad9; font-size:14px;vertical-align:middle;text-align:center;white-space:nowrap; " ><div style="width: 100px;">Item CP</div></td>
<td style="font-size:14px">
<asp:Label ID="lblMessagePost" runat="server" Text="No Records found" Visible ="false" ForeColor="Red"></asp:Label>
<asp:Repeater ID="rptStylePostOrder" runat="server" OnItemDataBound="rptStylePostOrder_ItemDataBound">
<ItemTemplate>
<table border="1" style="border-collapse:collapse">
<tr>
<td class="stylestatusReport">
<div style="width:100px !important"><asp:HiddenField ID="styleid" runat="server" Value='<%# Container.DataItem.ToString() %>'/>
<asp:Label ID="lblStyle" runat="server"></asp:Label></div>
</td>
<td>
<asp:Label ID="lblNoMilestonePost" runat="server" Text="No Records found" Visible ="false" ForeColor="Red"></asp:Label>
<asp:Repeater ID="rptPO" runat="server" OnItemDataBound="rptPO_ItemDataBound">
<ItemTemplate>
<table>
<tr>
<td style="word-wrap:break-word;width:60px;vertical-align:middle;text-align:center;">
<div style="width:60px">
<asp:Label ID="lblPostOrderNumber" runat="server"></asp:Label>
<asp:HiddenField ID="hdnStylePOID" runat="server" Value='<%# Container.DataItem.ToString() %>'/></div>
</td>
<td>
<asp:DataList ID="dataListPostOrder" runat="server" RepeatDirection="Horizontal" OnItemDataBound="dataListPostOrder_ItemDataBound">
<ItemTemplate>
<table border="1" style="border-collapse:collapse">
<tr>
<td style="word-wrap:break-word;width:110px; height:60px;background-color:#90cad9 ; font-size:11px;vertical-align:middle;text-align:center">
<div style="word-wrap:break-word;width:100%; font-size:13px"><asp:Label ID="lblMilestoneValuePost" runat="server" Text='<%# Eval("MilestoneName") %>'></asp:Label></div>
</td>
</tr>
<tr>
<td style="text-align:left">
<asp:Table ID="tblStatusPost" runat="server" Width="100%">
<asp:TableRow ID="rowStatusPost" runat="server">
<asp:TableCell ID="cellStatus1Post" Width="25px" runat="server">
<div style="width:100px;text-align:justify;"><asp:Label ID="lblForecastedDatePost" Font-Size="13px" runat="server" Width="50%" ForeColor="Black"></asp:Label></div></asp:TableCell>
<asp:TableCell ID="cellStatusPost" runat="server"><div style="width:100px;text-align:center">
<asp:Label ID="lblStatusPost" Font-Size="13px" runat="server" Width="100%" ForeColor="White"></asp:Label></div></asp:TableCell></asp:TableRow></asp:Table>
<asp:HiddenField ID="hdnPlannedDatePost" runat="server" Value='<%# Eval("MilestonePlannedDate") %>'></asp:HiddenField>
<asp:HiddenField ID="hdnRevisedDatePost" runat="server" Value='<%# Eval("MilestoneRevisedDate") %>'></asp:HiddenField>
<asp:HiddenField ID="hdnActualDatePost" runat="server" Value='<%# Eval("MilestoneActualDate") %>'></asp:HiddenField>
<asp:HiddenField ID="hdnMilestoneStatusPost" runat="server" Value='<%# Eval("MilestoneStatus") %>' />
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
</td>
</tr>
</table>
<%-- </asp:Panel>--%>
</td>
</tr>
</table>
[Below is the image of the table that is being displayed in excel.]
http://i.stack.imgur.com/JhHQo.png
actual image
[1]: http://i.stack.imgur.com/ghl8I.png

Having Issues with using VISIBLE. My Javascript doesnt seem to be handling the event when the check box is clicked

All of my hidden fields have ID's. And in my JavaScript in trying to set the visible from false to true on the payment selection. The Cash payment should just display the address to be sent to. The credit card payment comes up with text boxes and labels in order to process the payment online. But when I run the script the wont appear with the checkbox selection. I assigned an onClick event and still doesnt work. Any suggestions?
<%# Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="ShoppingCart.aspx.cs" Inherits="ShoppingCart" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
<head>
<script type="text/javascript">
function paymentFunction() {
if (document.getElementById("rbCash").checked) {
document.getElementById("lbCash").visible = true;
document.getElementById("lbCash2").visible = true;
document.getElementById("lbCash3").visible = true;
document.getElementById("lbCash4").visible = true;
}
else
{
if(document.getElementById("rbCreditCard").checked)
{
document.getElementById("lbCard").visible = true;
document.getElementById("lbCardNum").visible = true;
document.getElementById("lbCVV").visible = true;
document.getElementById("lbexp").visible = true;
document.getElementById("ddlCard").visible = true;
document.getElementById("tbCnum").visible = true;
document.getElementById("tbcvvnum").visible = true;
document.getElementById("tbexp").visible = true;
}
}
}
</script>
<style type="text/css">
.style1
{
width: 100%;
}
.style2
{
width: 100%;
}
.style3
{
width: 130px;
}
</style>
</head>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<table class="style2">
<tr>
<td class="style3">
Payment Type:</td>
<td>
<asp:CheckBox ID="rbCash" runat="server" onClick="paymentFunction()" Text="Cash" ClientIDMode="Static"/>
<asp:CheckBox ID="rbCreditCard" runat="server" onClick="paymentFunction()" Text="Credit Card" />
</td>
</tr>
<tr>
<td class="style3">
</td>
<td>
<asp:Label ID="lbCash" runat="server" ForeColor="Black"
Text="Please Send Payment To:" Visible="False" ClientIDMode="Static"></asp:Label>
</td>
</tr>
<tr>
<td class="style3">
</td>
<td>
<asp:Label ID="lbCash2" runat="server" ForeColor="Black"
Text="Wild Style Shoes" Visible="False" ClientIDMode="Static"></asp:Label>
</td>
</tr>
<tr>
<td class="style3">
</td>
<td>
<asp:Label ID="lbCash3" runat="server" ForeColor="Black"
Text="1808 West Avenue" Visible="False" ClientIDMode="Static"></asp:Label>
</td>
</tr>
<tr>
<td class="style3">
</td>
<td>
<asp:Label ID="lbCash4" runat="server" ForeColor="Black"
Text="Chicago, IL 88947" Visible="False" ClientIDMode="Static"></asp:Label>
</td>
</tr>
<tr>
<td class="style3">
<asp:Label ID="lbcard" runat="server" Text="Card Type" Visible="False"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlCard" runat="server" Visible="False">
<asp:ListItem>Select A Card</asp:ListItem>
<asp:ListItem>Visa</asp:ListItem>
<asp:ListItem>Discover</asp:ListItem>
<asp:ListItem>MasterCard</asp:ListItem>
<asp:ListItem>American Express</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style3">
<asp:Label ID="lbcardnum" runat="server" Text="Card Number:" Visible="False"></asp:Label>
</td>
<td>
<asp:TextBox ID="tbCnum" runat="server" Visible="False" Width="200px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style3">
<asp:Label ID="lbCVV" runat="server" Text="CVV Number" Visible="False"></asp:Label>
</td>
<td>
<asp:TextBox ID="tbcvvnum" runat="server" Visible="False" Width="58px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style3">
<asp:Label ID="lbexp" runat="server" Text="Expiration Date" Visible="False"></asp:Label>
</td>
<td>
<asp:TextBox ID="tbexp" runat="server" Visible="False"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style3">
</td>
<td>
<asp:Button ID="Button1" runat="server" Text="Submit Payment" Visible="False" />
</td>
</tr>
</table>
<p>
</p>
<p>
</p>
<p>
Thank You For Shopping With Us:<br />
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
</asp:Content>
If you set Visible = false on the server side like you are doing, then the server will not render the control.
You probably want to do the following:
<asp:Label ID="lbCash" runat="server" ForeColor="Black"
Text="Please Send Payment To:" style="visibility:hidden" ClientIDMode="Static"></asp:Label>
Then in the javascript do something like this:
document.getElementById('lbCash').style.visibility = 'visible';

Asynchronously extend multiple CollapsiblePanels

I have a webpage that is setup like so:
There is a ListView that has an item for each record in one of our SQL tables. Each of these items has a CollapsiblePanel in it that can be expanded to show more detail about the given record.
My Issue:
When I expand one panel and then wait for it to complete...everything is okay. However, if I try to expand multiple of those collapsiblepanels at once (meaning before the first panel is completely expanded)...only the last panel expands showing its data.
My Question:
Is it possible to have each of these panels expand asynchronously? Seems silly that I have to wait for one panel to extend before I can extend another.
My aspx:
I modified this aspx a little bit by removing unneeded code to make it less confusing.
<asp:UpdatePanel ID="UpdPnlBGList" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
<ContentTemplate>
<div class="content-box">
<asp:Panel ID="pnlBGResult" runat="server">
<asp:ListView ID="lvSummary" runat="server" ItemPlaceholderID="placeholderBGList"
OnItemDataBound="lvSummary_ItemDataBound" OnItemCommand="lvSummary_ItemCommand">
<LayoutTemplate>
<table runat="server" id="tblList" cellpadding="0" cellspacing="0" border="0" style="table-layout: fixed;">
<tr id="placeholderBGList" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr runat="server">
<td>
<asp:UpdatePanel ID="UpdBgItemTemplate" runat="server" ChildrenAsTriggers="true"
UpdateMode="Conditional">
<ContentTemplate>
<div class="bgList">
<asp:Panel ID="pnlSummary" runat="server">
<table id="tblBgList" runat="server" cellpadding="0" cellspacing="0" border="0" style="border-collapse: collapse;
border-spacing: 0px;">
<tr>
<td class="imageColumn">
<asp:ImageButton ID="imgCollapsible" CssClass="first" ImageUrl="~/Images/branding/plus.gif"
runat="server" CommandName="ExpandCollapse" Style="cursor: pointer; padding-right: 5px;" />
</td>
<td width="600px">
<asp:Label ID="lblBGName" runat="server" Text='<%# Eval("BGName")%>' CssClass="bgName"></asp:Label>
<asp:Label ID="lblDatePosted" runat="server" CssClass="datePosted"></asp:Label>
</td>
<td colspan="2">
<div style="float: right;">
<asp:Label ID="lblAccountNumber" runat="server" CssClass="accountReview"></asp:Label>
<asp:Label ID="lblAccountNumberText" runat="server" CssClass="accountReview"></asp:Label>
</div>
</td>
</tr>
<tr>
<td>
</td>
<td width="600px">
<asp:Label ID="lblBillToAddress" runat="server" Text='<%# Eval("BillToAddress")%>'
CssClass="billToAddress" Style="font-weight: bold;"></asp:Label>
</td>
<td>
<div style="float: right;">
<asp:ImageButton ID="imgViewAuthLetter" ImageUrl="~/Images/branding/document.jpeg"
CssClass="first" runat="server" OnClick="imgViewAuthLetter_Click" />
<asp:LinkButton ID="lnkAuthorizationLetter" runat="server" Text="View authorization letter"
class="link_button" OnClick="lnkAuthorizationLetter_Click" OnClientClick="dirtySuppress();"
OnPreRender="addTrigger_PreRender" />
</div>
</td>
<td width="70px" style="float: right;">
<div style="float: right;">
<asp:HyperLink ID="lnkExportImage" runat="server" ImageUrl="/Images/branding/export.jpg"
CssClass="hiperlinkExport" OnClick="dirtySuppress();" />
<asp:HyperLink ID="lnkExportText" runat="server" Text="Export" CssClass="hiperlinkExport"
OnClick="dirtySuppress(); precheckURL(this.href); return false;" />
</div>
</td>
</tr>
<tr>
<td colspan="4" style="padding: 0px;">
<asp:Panel Style="margin-left: 50px;" ID="pnlDetails" runat="server">
<of:AccountNumberListControl ID="accountNumberList" runat="server"></of:AccountNumberListControl>
</asp:Panel>
<cc1:CollapsiblePanelExtender ID="cpe" runat="Server" TargetControlID="pnlDetails"
CollapsedSize="0" Collapsed="True" ExpandControlID="imgCollapsible" CollapseControlID="imgCollapsible"
AutoCollapse="False" AutoExpand="False" ScrollContents="false" ImageControlID="imgCollapsible"
ExpandedImage="~/Images/branding/minus.gif" CollapsedImage="~/Images/branding/plus.gif"
ExpandDirection="Vertical" />
</td>
</tr>
<tr>
<td>
</td>
<td colspan="3" style="padding: 0px;">
<div class="itemSeperator" id="divItemSeperator" runat="server">
</div>
</td>
</tr>
</table>
</asp:Panel>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
<asp:HiddenField ID="hdfAccountNumberListControlID" runat="server" Value="" />
<asp:HiddenField ID="hdfAccountNumerID" runat="server" Value="" />
</asp:Panel>
</div>
<of:CustomerSetupExportPopInControl ID="customerSetupExportPopIn" runat="server" />
</ContentTemplate>
My codebehind:
This is the code that is executed when you expand the panel. There are several controls that is populated.
private void ExpandBillingGroup(ListViewDataItem item)
{
Label accountNumberLabel;
Label accountNumberText;
HtmlControl itemSeperator;
AccountNumberListControl accountNumberList;
// set properties for fedex account number label and text.
accountNumberLabel = (Label)item.FindControl("lblAccountNumber");
accountNumberLabel.Text = "FedEx account number: ";
accountNumberLabel.CssClass = "fedExAccountNumberLabel";
accountNumberText = (Label)item.FindControl("lblAccountNumberText");
accountNumberText.Text = lvSummary.DataKeys[item.DisplayIndex].Values["FedExAccountNumber"].ToString();
accountNumberText.CssClass = "fedExAccountNumberText";
//set the properties for Export
var lnkExportImage = (HyperLink)item.FindControl("lnkExportImage");
lnkExportImage.Visible = true;
var lnkExportText = (HyperLink)item.FindControl("lnkExportText");
lnkExportText.Visible = true;
//When expanded populate Customer Setup Export control
customerSetupExportPopIn.BillingGroupID = lvSummary.DataKeys[item.DisplayIndex].Values["BillingGroupID"].ToString();
//When expanded populate AccountNumberlistControl
accountNumberList = (AccountNumberListControl)item.FindControl("accountNumberList");
if (accountNumberList != null)
{
//since we make the AccountNumberListControl not visible on collapse we have to make it visible when we expand
accountNumberList.Visible = true;
//Set the properties
accountNumberList.BillingGroupID = lvSummary.DataKeys[item.DisplayIndex].Values["BillingGroupID"].ToString();
accountNumberList.FedExAccountNumber = lvSummary.DataKeys[item.DisplayIndex].Values["FedExAccountNumber"].ToString();
accountNumberList.BillingGroupName = ((Label)lvSummary.Items[item.DisplayIndex].FindControl("lblBGName")).Text;
accountNumberList.BillToAddress = ((Label)lvSummary.Items[item.DisplayIndex].FindControl("lblBillToAddress")).Text;
accountNumberList.FirstItemNeedsToExpand = BillingGroupIsResolved;
accountNumberList.GetListOfAccountNumbers(lvSummary.DataKeys[item.DisplayIndex].Values["BillingGroupID"].ToString(), VendorID);
}
//set the properties for itemSepeartor
itemSeperator = (HtmlControl)item.FindControl("divItemSeperator");
itemSeperator.Attributes.Add("class", "itemSeperatorExpanded");
UpdatePanel upd = (UpdatePanel)item.FindControl("UpdBgItemTemplate");
upd.Update();
}
Thanks,
Holt
EDIT: Fixed grammar and title issues

Categories