Not able to hide Table row/message in code behind using c# - c#

On Combo box selection change event i set the visible property of table and row to hide the message. But its not working.
Here is my code :
<telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0">
<telerik:RadPageView ID="RadPageViewCaregiver" runat="server">
<div class="container">
<telerik:RadToolTipManager ID="RadToolTipManager1" OffsetY="-1" HideEvent="ManualClose"
Width="200px" Height="250px" runat="server" OnAjaxUpdate="OnAjaxUpdate" RelativeTo="Element"
Position="MiddleLeft" ManualClose="True" ShowEvent="OnClick">
</telerik:RadToolTipManager>
<table border="0" cellpadding="0" cellspacing="0" style="width: 100%; height: 100%">
<tr>
<td align="center" valign="top" style="width: 100%">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr height="30px" valign="top" id="trmessage" runat="server" visible="false">
<td valign="middle" align="center">
<table border="0" cellpadding="0" cellspacing="0" width="98%" id="tbluser" runat="server"
visible="False">
<tr id="Tr1" runat="server">
<td id="Td1" align="left" runat="server">
<asp:Label ID="lblmessage" runat="server"></asp:Label>
</td>
</tr>
</table>
</td>
</tr>
I also tried to set the style for display to 'none' instead of visible to 'false' but it doesn't work either.
Can you give Any solution??

try display property to hide table. try this set of code.
tblAssignPatientMessage.Style.Add("display","none");
if the table style is set to be none then the tr style will also set to be hidden. if that doesn't work try this
trAssignPatientParentRow.Style.Add("display","none");
use this set of code to make the table visible.
tblAssignPatientMessage.Style.Add("display","block");
and for tr add this.
trAssignPatientParentRow.Style.Add("display","block");
and make sure that your table is not using any cssclass.

Related

ASP.NET UpdatePanel Set value for Checkbox

I am using a ListView that contains a checkbox. I would like the checkbox to automatically update a bit field in my database from False to True (or visa versa) when the box is checked.
I am not familiar with the update panel and I'm struggling to find a way to achieve this.
My List View
<asp:ListView ID="ListView1" runat="server" DataKeyNames="NotificationID" DataSourceID="SqlDataSource1">
<EmptyDataTemplate>
<table runat="server" style="">
<tr>
<td>No notifications exist.<br /> NOTE: You must be logged in to see notificaitons</td>
</tr>
</table>
</EmptyDataTemplate>
<ItemTemplate>
<tr class="odd gradeX">
<td><span style="display: none;"><%# ("00000000" + Eval("DateDescNumber")).TxtStrRight(8) %> - </span><%# GlobalUtilities.GetDiffDate(Convert.ToDateTime(Eval("DateTimeLogged"))) %></td>
<td><%# Eval("UserName") %></td>
<td><%# Eval("NotificationTitle") %></td>
<td class="center"><%# Eval("NotificationMessage") %></td>
<td class="center">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:updatepanel id="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:CheckBox ID="CheckBoxMarkedAsRead" runat="server"
Checked='<%# Eval("MarkedAsRead") %>'
AutoPostBack="true"
Visible="true"
Text =" Not Selelected"
oncheckedchanged="CheckBox_MarkedAsRead_CheckedChanged" />
</ContentTemplate>
</asp:updatepanel>
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table cellpadding="0" cellspacing="0" border="0" class="responsive dynamicTable display table table-bordered" width="100%">
<thead>
<tr>
<th style="width:80px">Date</th>
<th>From</th>
<th>Notice</th>
<th>Description</th>
<th class="ch" style="width:53px;">Read</th>
</tr>
</thead>
<tbody>
<asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
</tbody>
</table>
</LayoutTemplate>
</asp:ListView>
I have gone as far as creating the CheckBox_MarkedAsRead_CheckedChanged event in my Code behind (at least I think this is what I should do) but my attempts to script a solution in the code behind has been fail after fail.

html input of type File wrapped inside ASP: Panel is not disabled when panel is disabled

I have wrapped HTML Input control of type File inside ASP:Panel control(which is wrapped inside update panel).
When I disable ASP:Panel control, input control is still enable. Please helpme out
ASPX Code :
<asp:Panel ID="pnlBrowseCSV" runat="server" Enabled="true">
<table>
<tr>
<td align="left" valign="top" style="height: 30px; width: 160px;">
<strong>CSV File:</strong>
</td>
<td style="height: 30px">
<input type="file" id="csvFile" runat="server"
onkeydown="return false" style="width: 350px; background-color:white"/>
<strong>(*.csv)</strong>
</td>
<td style="height: 30px">
<ASP:Button ID="btnValidate" Text="Validate" runat="server"
OnClick="btnValidate_Click" />
</td>
</tr>
</table>
</asp:Panel>
Using visible attribute instead of Enabled.
<asp:Panel ID="pnlBrowseCSV" runat="server" Visible="False">
This issue is by design. What you can do rather is write one extra line of code to disable File upload where you disable the panel.
pnlBrowseCSV.Enabled = false;
csvFile.Enabled=false;

How to build a ListView and fill it from the codebehind

I want to fill my ListView from codebehind and want to know how to build the fields.
I saw this example, and I'd like to now if the only way to build a ListViews fields is using tables. If not, what would be another way to do that? I tried only filling the ListView with datasource, like this:
ListView1.DataSource = ds;
ListView1.DataBind();
But it gave me an error:
An ItemTemplate must be defined on ListView 'ListView1'.
What is the best way to use ListView? The error happens only when I use ListView1.DataBind();
PS: I'll need only one row to display, so if someone has a better control to use than ListView, I'm reading.
UPDATE
Now I'm trying like this:
<asp:ListView ID="ListView1" runat="server">
<LayoutTemplate>
<table border="0" cellpadding="1">
<tr style="background-color: #E5E5FE">
<th align="left"><asp:LinkButton ID="lnkResp" runat="server"></asp:LinkButton></th>
<th align="left"><asp:LinkButton ID="lnkProj" runat="server"></asp:LinkButton></th>
<th align="left"><asp:LinkButton ID="lnkFunc" runat="server"></asp:LinkButton></th>
<th<></th>
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td><asp:Label runat="server" ID="lblResp"><%#Eval("responsavel") %></asp:Label></td>
<td><asp:Label runat="server" ID="lblProj"><%#Eval("projeto") %></asp:Label></td>
<td><asp:Label runat="server" ID="lblFunc"><%#Eval("funcionalidade") %></asp:Label></td>
</tr>
</ItemTemplate>
</asp:ListView>
But I got a new error:
An item placeholder must be specified on ListView 'ListView1'.
Specify an item placeholder by setting a control's ID property to "itemPlaceholder".
The item placeholder control must also specify runat="server".
In your LayoutTemplate, you need a <asp:PlaceHolder runat="server" ID="itemPlaceholder" /> in the table tag.
<LayoutTemplate>
<table border="0" cellpadding="1">
<tr style="background-color: #E5E5FE">
<th align="left"><asp:LinkButton ID="lnkResp" runat="server"></asp:LinkButton></th>
<th align="left"><asp:LinkButton ID="lnkProj" runat="server"></asp:LinkButton></th>
<th align="left"><asp:LinkButton ID="lnkFunc" runat="server"></asp:LinkButton></th>
<th<></th>
</tr>
<asp:PlaceHolder runat="server" ID="itemPlaceholder" />
</table>
</LayoutTemplate>

ASP.NET Repeater Control Checkbox issue

Overview: Clicking on text of first CheckBox in a repeater control clicks the last one. I know why this is happening; association of label tag with element id chkMarkedForDeletion and when that label is clicked it selects the last CheckBox, as all the CheckBoxes have same ID.. damn you repeater control!! I am wondering if there is any way to avoid this? Easy way would be to create individual labels and associate correctly to each CheckBox but that defeats the supposed default behaviour of a CheckBox.
Repeater code:
<asp:Repeater ID="childNodesDataRepeater" runat="server">
<ItemTemplate>
<table style="width: 100%;" cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="width: 200px;">
<asp:CheckBox ID="chkMarkedForDeletion" runat="server" EnableViewState="true" Text="Remove"
Checked='<%# DataBinder.Eval(Container.DataItem, "IsMarkedForDeletion") %>' />
</td>
<td>
</td>
<td style="width: 200px;">
<asp:CheckBox ID="chkHighImpactCause" runat="server" EnableViewState="true" Text="High Impact Cause"
Checked='<%# DataBinder.Eval(Container.DataItem, "IsHighPriority") %>' />
</td>
</tr>
<tr>
<td colspan="3">
<asp:Label ID="header002" runat="server" Text="What caused this problem?" />
</td>
</tr>
<tr>
<td colspan="3">
<asp:TextBox ID="txtProblemCausedBy" runat="server" EnableViewState="true" Width="100%"
Text='<%# DataBinder.Eval(Container.DataItem, "Description") %>' /><br />
</td>
</tr>
<tr>
<td colspan="3" style="height: 5px;">
<hr />
<asp:HiddenField ID="nodeIdentifier" runat="server" EnableViewState="true" Value='<%# DataBinder.Eval(Container.DataItem, "AnalysisID") %>' />
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
Generated HTML Code for CheckBox:
<INPUT id=chkMarkedForDeletion type=checkbox name=TabContainer$tabProblemResolution$frmProblemResolution1$childNodesDataRepeater$ctl00$chkMarkedForDeletion>
<LABEL for=chkMarkedForDeletion>Remove</LABEL>
...
...
<INPUT id=chkMarkedForDeletion type=checkbox name=TabContainer$tabProblemResolution$frmProblemResolution1$childNodesDataRepeater$ctl02$chkMarkedForDeletion>
<LABEL for=chkMarkedForDeletion>Remove</LABEL>
Issue:
Thanks,
Abhi
Make sure the ClientIDMode on the repeater is not set to "Static".
This setting is inheritable from the parent, which goes all the way up to web.config. So if you have to set the ClientIDMode explicitly on the repeater, it means that some parent overrides the default (Predictable) to "Static".

Read textbox from ASP.net page that repeated n times

I have an asp.net web page that's has a number of controls that are repeated according to number of records retrieved from the database, and I wanna read the values of those text boxes after users enter values in them, so please if anyone can help me on this issue.
I have an example of my work
<% System.Data.SqlClient.SqlDataReader myDReader = myDatabaseConnector.getDataFromDBAsSQLDataReader("SELECT * from students);
while(myDReader.Read())
{ %>
<asp:TextBox ID="txtCourseInfo" Test="" EnableViewState="false" CssClass="dataEntrySearchDataText" ReadOnly="true" runat="server"></asp:TextBox>
<% } %>
This a sample of what I have mean from my question in which I want to retrieve the value of txtCourseInfo in my C# code behind
You could use a Repeater to do this:
<asp:repeater id="rptCourses" runat="server" DataSourceID="dsCourseInfo"
<ItemTemplate>
<asp:TextBox ID="txtCourseInfo" Text='<%#Eval("StudentName")#%>' EnableViewState="false" CssClass="dataEntrySearchDataText" ReadOnly="true" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:Repeater>
<asp:sqldatasource id="dsCourseInfo"
ConnectionString="<%$ ConnectionStrings:YourConnectionString %>"
Select Command="Select * from Students">
</asp:sqldatasource>
That's all you need. from code behind you can iterate through the controls on the repeater and grab the information.
Notice the Eval expression on the text field. I used "StudentName" as an example, but you should use one of the column names returned by the select statement
Additional comments:
Don't do select * from ... It's a bad practice in many respects. Always specify the columns you need, even if you need all.
I realize that you disable viewstate on the textbox. I don't know the reason for doing this but be aware that the info won't be persisted on subsequent postbacks unless you enable it on the control.
UPDATE
Yes, you can have tables inside repeaters. Look at the example below:
<ItemTemplate>
<table runat="server" style="color: White; background-color: #3A4F63;" visible="false"
id="headerTable">
<tr>
<td colspan="3" align="center">
<asp:Label ID="headerTitle" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td style="width: 200px; background-color: #3A4F63; color: White;">
Image
</td>
<td style="width: 200px;">
Studen Name
</td>
<td style="width: 200px;">
Birth Date
</td>
</tr>
</table>
<table>
<tr>
<td style="width: 200px;">
<asp:Image ID="img" runat="server" ImageUrl='<%#Eval("ImageUrl") %>'></asp:Image>
</td>
<td style="width: 200px;">
<asp:Label ID="lblName" runat="server" Text='<%#Eval("Name") %>'></asp:Label>
</td>
<td style="width: 200px;">
<asp:Label ID="lblBirthDate" runat="server" Text='<%#Eval("BirthDate") %>'></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>

Categories

Resources