Pop-up is created as given in image.
In given image ListView is used. In each row last dropdown depends on the second dropdown, and the second depends on the first. Entire dropdown hierarchy is kept in one Update panel for each row. If I select first dropdown I am able to change second.
Dropdowns in layout template and insert template are kept in Update panel and it's working properly, but if I keep dropdowns in item template in Update panel I am getting 500 error.
Tried code is as follows-
<ItemTemplate>
<tr>
<td>
<asp:TextBox ID="TextBox1" runat="server" />
</td>
<td>
<asp:Image ID="UserRoleImage" runat="server" />
</td>
<td>
--CheckBox Code--
</td>
<td>
--CheckBox Code--
</td>
<td>
--CheckBox Code--
</td>
<asp:updatepanel id="Updatepanel1" runat="server" updatemode="Conditional">
<ContentTemplate>
<td style="width:10%">
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
</td>
<td style="width:10%">
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList>
</td>
<td style="width:10%">
<asp:DropDownList ID="DropDownList3" runat="server">
</asp:DropDownList>
</td>
</ContentTemplate>
</asp:updatepanel>
<td>
<asp:ImageButton ID="DeleteButton" runat="server" CommandName="Delete" />
</td>
<td></td>
</tr>
</ItemTemplate>
If I remove Update panel it works fine but on dropdown change my pop-up is getting closed. I want to update only one row of listview of pop-up.
Exact same design is added in layout template and insert template.
Got the cause of crash. Since same id of Update panel was using in Item template and Alternate template. I removed Alternate template from list view and Table is rendering perfectly how I was looking for.
Related
I have registration form for users to fill up. In there, one field is there to which if user checks on the button a text box shoulld be enabled to enter the number. I have used following code :
<asp:UpdatePanel ID="upMSME" runat="server">
<ContentTemplate>
<tr>
<td colspan="2">
<asp:Label ID="lblMSME" runat="server" Text="Whether covered under MSME (Tick whichever is applicable)"></asp:Label>
<asp:CheckBox AutoPostBack="true" Checked="true" ID="chbMSME" runat="server" OnCheckedChanged="chbMSME_CheckedChanged" ClientIDMode="AutoID"/>
</td>
</tr>
<tr id="trMSMENo" runat="server">
<td>
<asp:Label ID="lblMSMENo" runat="server" Text="MSME Number" CssClass="alignTop"></asp:Label>
</td>
<td class="ValueBox">
<asp:TextBox ID="txtMSMENo" runat="server" MaxLength="75"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvMSMENo" runat="server" ForeColor="Red" ErrorMessage="*" ControlToValidate="txtMSMENo" ValidationGroup="vgVendor"></asp:RequiredFieldValidator>
</td>
</tr>
</ContentTemplate>
</asp:UpdatePanel>
However I searched over internet and found that by setting the ClientIDMode="AutoID" the issue is resolved. But in my case after setting the property there is still full postback occurred.
I have another update panel also in this form, does it make any difference?
What am I missing?
I added a couple of fields manually in my ASPX page which is actually holding a FormView. By manually, I mean by directly typing code in the Markup editor.
Now when I'm trying to access those controls in the code behind, nothing comes up in intellisense.
I deleted the designer.cs file and right clicked the ASPX page and chose Convert to web application, still no go.
The designer file's got the FormView control defined alright, but nothing about its child controls.
Do I really need to use FindControl to get this working ? Tell me if you need some code posted because at the moment maybe I'm just a bit confused about ASP.NET is actually working (or not at this moment).
Here's the markup code:
<%# Page Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="True" CodeBehind="WebForm_PatientForm.aspx.cs" Inherits="WebAppWalkthrough.WebForm_PatientForm" Title="Employee form" %>
<%# MasterType VirtualPath="~/Site.Master" %>
<asp:Content ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ContentPlaceHolderID="MainContent" runat="server">
<asp:FormView ID="PatientForm" runat="server" DefaultMode="Edit">
<EditItemTemplate>
<table>
<tr>
<td class="FormViewHeader">
Patient Name:
</td>
<td>
<asp:TextBox ID="PatientName" ReadOnly="true" runat="server" Text='<%# Bind("FullName") %>'></asp:TextBox>
</td>
</tr>
<tr>
<td class="FormViewHeader">
Patient ID:
</td>
<td>
<asp:TextBox ID="PatientID" ReadOnly="true" runat="server" Text='<%# Bind("patientid") %>'></asp:TextBox>
</td>
</tr>
<tr>
<td class="FormViewHeader">
Eligibility
</td>
<td>
<asp:DropDownList runat="server" ID="Eligibility" SelectedValue='<%# Bind("service_executive_eligibility") %>' >
<asp:ListItem Value="" Text="N/A" />
<asp:ListItem Value="True" Text="Yes" />
<asp:ListItem Value="False" Text="No" />
</asp:DropDownList>
</td>
</tr>
</table>
<asp:LinkButton ID="LinkButton2" runat="server" OnCommand="UpdatePatientInfo" Text="UpdateInfo" CommandArgument='<%# Bind("patientid") %>'>Update</asp:LinkButton>
<asp:LinkButton ID="LinkButton3" runat="server" OnCommand="CancelEditPatient" CommandName="CancelUpdate" Text="CancelInfo">Cancel</asp:LinkButton>
</EditItemTemplate>
<InsertItemTemplate>
<table>
<tr>
<td class="FormViewHeader">
Employee First Name:
</td>
<td>
<asp:TextBox ID="FirstName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="FormViewHeader">
Employee Last Name:
</td>
<td>
<asp:TextBox ID="LastName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="FormViewHeader">
Email address:
</td>
<td>
<asp:TextBox ID="EmailAddress" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="FormViewHeader">
Work phone number:
</td>
<td>
<asp:TextBox ID="PhoneNumber" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="FormViewHeader">
Eligibility
</td>
<td>
<asp:DropDownList runat="server" ID="Eligibility">
<asp:ListItem Value="True" Text="Yes" />
<asp:ListItem Value="False" Text="No" />
</asp:DropDownList>
</td>
</tr>
</table>
<asp:LinkButton ID="LinkButton5" runat="server" OnCommand="AddEmployee" Text="Add Employee">Add</asp:LinkButton>
</InsertItemTemplate>
</asp:FormView>
</asp:Content>
Even if I add the controls manually in the designer file, I get a null reference error in the code behind at run time (even if intelisense picks up FirstName the object is null at runtime).
EDIT: I will try installing VS2010 SP1 and this hotfix I found and post the results.
EDIT 2: So I installed VS2010 SP1 which didn't solve the issue. I could not install the hotfix as my system is x64.
So I ditched VS2010 and tried with VS2013, which still doesn't pickup the markup controls.
Even Page.FindControl("ControlName") returns null. Something is very rotten with that webpage or VS2013...
Thanks.
I encountered a problem that seems similar with Telerik UI components for WebForms before. I wanted to access items that were defined inside of a template in a grid, but unfortunately the only way to do that was to dig into child elements of that grid. That inner elements were not present in the designer.cs file as well.
I am not sure about that, but it can be a common behavior of nested elements in WebForms.
I have a ListView Control in Asp.net 4.0 C#
I am attempting to make the default mode = Edit Mode with text boxes. So I took the Item Template (the default template) and replaced my databound labels with TextBoxes.
It works ok. Except the text Boxes only apply to every other row. So half the rows are text boxes on Page Load and half the Roes are still Labels. Here is my code:
<ItemTemplate>
<tr style="">
<td>
<asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>' />
</td>
<td>
<asp:TextBox ID="DiscountPercentageTextBox" runat="server"
Text='<%# Bind("DiscountPercentage") %>' />
</td>
<td>
<asp:TextBox ID="CashTextBox" runat="server" Text='<%# Bind("Cash") %>' />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table>
<thead>
<tr>
<th>Title </th>
<th>DiscountPercentage</th>
<th>Cash</th>
</tr>
</thead>
<tbody>
<asp:PlaceHolder runat="server" ID="itemPlaceholder" />
</tbody>
</table>
</LayoutTemplate>
And here is the result:
You see? Every other row is a textbox. I need all rows to be textboxes. What am i doing wrong?
Huh, do you have an AlternatingItemTemplate defined? The ListVIew has no intelligence to make the original fields as labels....
Try making the ALternatingItemTemplate as the ItemTemplate too, if you don't have one defined.
I have a repeater on my page which I use to display a list of search results. My issue is that the page keeps throwing me a
Parser Error Message: The server tag is not well formed.
error because the repeater has no datasource
Repeater:
<asp:Repeater runat="server" ID="rptSearchResults" >
<HeaderTemplate>
<h3>Search results</h3>
</HeaderTemplate>
<ItemTemplate>
<table>
<tr>
<td>
<asp:Label runat="server" ID="lblTitle" Text="<%# Eval("title")%>"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label runat="server" ID="lblAdress" Text="<%# Eval("adress")%>"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label runat="server" ID="lblZipcode" Text="<%# Eval("zipcode")%>"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label runat="server" ID="lblCity" Text="<%# Eval("city")%>"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label runat="server" ID="lblType" Text="<%# Eval("type")%>"></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
Above this repeater is a form where users can type in search words for primarily title, adress, zipcode, city and type. The repeater isn't supposed to fill out untill the user clicks the button which triggers the search and thus adds a datasource to the repeater.
Is there a way to make it work like I want it to?
I don't think the lack of a data source is the problem - it should be fine. The error says "The server tag is not well formed." - this means there's a problem with the markup. A problem with an empty data source would cause a NullReferenceException or something similar. So, maybe the problem is your Label elements - try changing the Text attributes from this:
Text="<%# Eval("type")%>"
to this:
Text='<%# Eval("type")%>'
I think all the double quotes will confuse ASP.Net. Use a combination of single and double quotes.
What happens if you disable the repeater control by default? Does it still throw the exception?
If disabling it doesn't work I'd add it dynamically as and when you need it. So that you can keep your template you can strip it out to a user control so you only have to add the user control through code and not the entire item template.
You can only have one form runat="server" per page apparently.
My page has one form, where it loads in a list of names. This form allows you to add a new name to the list as well.
I've attatched an onclick event to each name in the listview. When you click on it, I need it to load the data into the edit form (next to the add form) with JavaScript code; I can do this fine.
But how do I structure it on the page to have two forms?
An illustration:
<table>
<tr>
<td style="width:50%;" valign="top">
<form runat="server" action="productCats.aspx?action=new&mid=2">
<div class="subHead">Create New Category</div>
<table class="settingTable">
<tr>
<td colspan="2"><b>Category Name</b></td>
</tr>
<tr>
<td>
<asp:TextBox ID="catName" runat="server" CssClass="tbox widebox"></asp:TextBox>
<asp:RequiredFieldValidator runat="server"
id="ValidatorName"
ControlToValidate="catName"
ErrorMessage="You need to enter a category name"
display="Dynamic" />
</td>
</tr>
<tr>
<td>This is the name of your category.</td>
</tr>
<tr>
<td colspan="2"><b>Parent Category</b></td>
</tr>
<tr>
<td>
<asp:ListBox SelectionMode="Single" Rows="8" id="parent" runat="server" CssClass="tbox widebox">
<asp:ListItem Selected="True" Text="Top Level" Value="0"></asp:ListItem>
</asp:ListBox>
<asp:RequiredFieldValidator runat="server"
id="RequiredFieldValidator1"
ControlToValidate="parent"
ErrorMessage="You need to select a parent"
display="Dynamic" />
</td>
</tr>
<tr>
<td>Choose a parent this category belongs to.</td>
</tr>
</table>
<asp:Button id="id" text="Create" runat="server" />
</form>
</td>
<td style="width:4%;">
</td>
<td valign="top">
<div class="subHead">Modify Category</div>
<form id="Form1" action="productCats.aspx?action=update&mid=2">
<table class="settingTable">
<tr>
<td colspan="2"><b>Category Name</b></td>
</tr>
<tr>
<td>
<asp:TextBox ID="newCatName" runat="server" Enabled="false" CssClass="tbox widebox"></asp:TextBox>
<asp:RequiredFieldValidator runat="server"
id="RequiredFieldValidator2"
ControlToValidate="newCatName"
ErrorMessage="Enter a new category name"
display="Dynamic" />
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
ASP.NET Web Forms works by having just one <form> element on a page, and getting this posted back to the same page every time something changes (postbacks). Trying to use multiple forms, and specifying custom action attributes on the form element is going against what the framework is designed to work with, and that's never really a good idea.
I would just try to get rid of the second <form> element, and remove the action attribute from the first <form>. Also, ASP.NET will be much happier if everything is inside the form, i.e. your <table> tags at the top of the page.
I'm not sure what your page is doing, but if you've got a TextBox and you're using the contents of this to add items to a ListBox, a more Web Forms-like approach would be to use some control to do a postback when the TextBox has been filled in, and then re-bind the ListBox to some kind of data source. Maybe use an UpdatePanel if you want an Ajax postback.
If you're more comfortable with JavaScript and query string parameters, maybe ASP.NET MVC would be a better fit.
By what I understood from your explanation, you want a functionality on this page of yours where when you click on one of the listitem in the list, the elements in the form2 needs to displayed and to modify the details... What I think is ... use two Panels and onclick of the item in ListBox you can show the Edit Panel and on the change of details and some other event like button click .. you can show the ListBox Panel with the changed detail.
Yes as Graham has mentioned you can use Ajax update panel to accomplish this.