That's it, really. I have a DetailsView and a button on my ASP.NET page, and the button always appears beneath the DetailsView. Using floating DIVs breaks things in other ways, so is there any method to suppress the line break after the DetailsView, and have it display inline with the button?
I've tried applying Display:Inline CSS to the DetailsView, but it didn't work.
EDIT - CODE ADDED BELOW
<asp:DetailsView ID="dvPremisesYardName" runat="server" datasourceid="SQLGeneralDetails" DefaultMode="Edit" AutoGenerateRows="False" FieldHeaderStyle-CssClass="fieldtitleyardname"
GridLines="None" onchange="hideControl('imgGeneralDetailsTick');" >
<Fields>
<asp:TemplateField HeaderText="Yard Name">
<EditItemTemplate>
<asp:DropDownList ID="ddlPremisesYardName" runat="server" DataSourceID="SQLPremisesLookup" DataTextField="PremisesYardName" DataValueField="PremisesID" AutoPostBack="True"
SelectedValue='<%# Bind("AdmissionPremisesID")%>' AppendDataBoundItems="True" >
<asp:ListItem Text="Unknown" Value="" />
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
</Fields>
</asp:DetailsView>
<asp:Button ID="btnPremisesAdd" runat="server" Text="Add New Premises" />
<asp:Button ID="btnPremisesEdit" runat="server" Text="Edit" />
As you stated, you do not want to use float div. The easiest way will be to use table.
Although we do not like to use table for page layout, I cannot think of other solution.
<table>
<tr>
<td><asp:DetailsView .../></td>
<td><asp:Button.../></td>
<td><asp:Button.../></td>
</tr>
</table>
Related
I have text box and a button in a gridview. The textbox has validation when the button is clicked. However the validation event never gets fired when the button is clicked a second time.
<asp:GridView ID="ChapterGridView"
EnableSortingAndPagingCallbacks="false"
AllowSorting="false"
AllowPaging="false"
runat="server"
AutoGenerateColumns="False"
CellPadding="2"
ForeColor="#333333"
GridLines="None"
Width="780px"
OnRowCommand="ChapterGridView_OnRowCommand"
ShowFooter="False"
AutoGenerateDeleteButton="true"
AutoGenerateEditButton="true"
onrowediting="ChapterGridView_RowEditing"
onrowdeleting="ChapterGridView_RowDeleting"
onrowcancelingedit="ChapterGridView_RowCancelingEdit"
onrowupdating="ChapterGridView_RowUpdating"
onrowupdated="ChapterGridView_RowUpdated"
DataKeyNames="ChapterId"
ValidationGroup="ChapterValidation"
Visible="true">
<FooterStyle BackColor="#eeeeee" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:TemplateField HeaderText="*End Page" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate><%# Eval("EndPage")%></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="EndPage" runat="Server" Text='<%# Eval("EndPage") %>'></asp:TextBox>
<asp:CustomValidator ID="TotalPagesValidator" ValidationGroup="ChapterValidation" OnServerValidate="TotalPages_ServerValidate" EnableClientScript="false" ErrorMessage="Number of pages in chapter are greater than number of pages in entire publication." Display="None" ControlToValidate="EndPage" runat="server" />
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="EndPage" runat="Server"></asp:TextBox>
<asp:CustomValidator ID="TotalPagesValidator2" ValidationGroup="ChapterValidation" OnServerValidate="TotalPages_ServerValidate" EnableClientScript="false" ErrorMessage="Number of pages in chapter are greater than number of pages in entire publication." Display="None" ControlToValidate="EndPage" runat="server" />
<asp:Button ID="btnInsert" runat="Server" Text="Insert" CommandName="Insert" UseSubmitBehavior="false" ValidationGroup="ChapterValidation" /></span>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
The same validation for edit works as expected. But not for the Insert button. Any suggestions?
1: Did you set the breakpoint to make sure there is a postback? Is the serverside validation called at all or not?
2: Can you try changing the ValidationGroup for Insert to something else than the Edit.
Edit There are issues using ValidatorCallOut with CustomValidator with ServerSide Validation.
http://forums.asp.net/t/1054676.aspx
http://programminginhell.wordpress.com/2008/08/03/hello-world/
Here's another way showing error in a jquery dialog: http://weblogs.asp.net/gurusarkar/archive/2011/03/28/part-3-showing-asp-net-server-side-messages-in-a-custom-dialog-server-side-with-asp-net-ajax.aspx
#TrekStir - thanks for pointing me in the right direction.
The problem was that there was code to make the footer invisible after a row was added. For some reason that was causing the validation code not to fire. I figured out a way to implement the functionality without setting the footer to invisible and this solved the problem.
I use Visual Studio 2010 in ASP.NET with C# code behind.
I have an ASP.NET page with code in Source View:
<p>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
</p>
If I switch in Design View and come back to Source View in VS, it unexpectedly removes the last </p> automatically.
Do you have the same problem in your Visual Studio?
Any ideas how to solve it?
Thanks.
P.S. Here my full code:
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h1>
Create Groups Types</h1>
<p>
<asp:DetailsView ID="uxCreateGroupsTypesDisplayer" runat="server" AutoGenerateRows="False"
DataKeyNames="GroupTypeId" DataSourceID="uxEntityDataSourceCreateGroupsTypes"
DefaultMode="Insert"
oniteminserted="uxCreateGroupsTypesDisplayer_ItemInserted"
oniteminserting="uxCreateGroupsTypesDisplayer_ItemInserting">
<Fields>
<asp:TemplateField HeaderText="TypeGroup" SortExpression="TypeGroup">
<InsertItemTemplate>
<asp:TextBox ID="uxTypeGroupInput" runat="server" Text='<%# Bind("TypeGroup") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="TypeGroup field is required."
ControlToValidate="uxTypeGroupInput" Text="*">
</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="uxRegularExpressionTypeGroup" runat="server"
ControlToValidate="uxTypeGroupInput" ErrorMessage="TypeGroup is too long or short. Change the field accordingly."
ValidationExpression="^.{4,40}$">*</asp:RegularExpressionValidator>
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Summary" SortExpression="Summary">
<InsertItemTemplate>
<asp:TextBox ID="uxSummaryInput" runat="server" Text='<%# Bind("Summary") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidatorSummary" runat="server" ErrorMessage="Summary field is required."
ControlToValidate="uxSummaryInput" Text="*">
</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="uxRegularExpressionSummary" runat="server" ControlToValidate="uxSummaryInput"
ErrorMessage="Summary is too long or short. Change the field accordingly." ValidationExpression="^.{4,256}$">*</asp:RegularExpressionValidator>
</InsertItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowInsertButton="True" />
</Fields>
</asp:DetailsView>
</p>
<p>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" /></p> <!-- The problem is here - This tag disappear if you switch from source view to design view and back to source view -->
<asp:EntityDataSource ID="uxEntityDataSourceCreateGroupsTypes" runat="server"
EnableFlattening="False"
EnableInsert="True" EntitySetName="CmsGroupsTypes">
</asp:EntityDataSource>
</asp:Content>
In VS2008, replaced:
<p>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" /></p>
With:
<p>
<asp:ValidationSummary ID="ValidationSummary1" runat="server"></asp:ValidationSummary></p>
This works, although does not agree with the closing tag in markup. Rendering is correct though in IE8.
Why does this summary control need to be enclosed in a paragraph tag? The Validation Summary renders as a block element.
Don't use Design View to edit markup, always use Source View, i.e. markup itself to edit markup.
IMO Design View just a simple, read-only, verify-purpose view.
I added a RequiredFieldValidator to my InsertItemTemplate, and it seems to be working fine. The problem I am having, however, is that now I cannot do anything else in the ListView (like edit or delete items) UNLESS the required field has a value. Is there some way I can manually do the validation when the user clicks the 'Insert' button on the InsertItemTemplate, or some other little trick I can perform so the user doesn't have to first type in a value just to delete something else in the list?
Thanks
A_Nablsi,
Please provide the code for your solution to turn the Insert New validation controls off when in Edit/Update mode or turn Edit/Update validation controls off when both the Edit and Insert Rows are active at the same time. This code using your notional solution fails with a null reference to the updateButton.
LinkButton updateButton = LVTasks.EditItem.FindControl("UpdateButtonTask") as LinkButton;
updateButton.CausesValidation = false;
The solution that works is adding Validation Groups.
Include ValidationGroup="myVGEdit" with your Validator Control(s) in the EditItemTemplate and your Update button.
Include ValidationGroup="myVGInsert" with your Validator Control(s) in the InsertItemTemplate and your Insert button.
<asp:ListView ID="LVTasks" runat="server"
DataKeyNames="IDTask"
DataSourceID="LDS_LVTasks"
InsertItemPosition="FirstItem"
oniteminserting="LVTasks_ItemInserting"
onitemupdating="LVTasks_ItemUpdating"
onitemcommand="LVTasks_ItemCommand"
>
<EditItemTemplate>
<asp:TextBox ID="TaskUpdateTextBox" runat="server"
Text='<%# Bind("Task") %>'
TextMode="MultiLine" Rows="1" Font-Bold="true" Width="300px"
/>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ErrorMessage="Please Set Task title"
ControlToValidate="TaskUpdateTextBox"
ValidationGroup="myVGUpdate"
/>
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CommandArgument='<%#Eval("IDTask") %>'
CommandName="Cancel"
CausesValidation="False"
ToolTip="Cancel - Abort - No Changes"><div class="Cancel"></div></asp:LinkButton>
<asp:LinkButton ID="UpdateButtonTask" runat="server"
CommandArgument='<%#Eval("IDTask") %>'
CommandName="Update"
CausesValidation="True"
ValidationGroup="myVGEdit"
ToolTip="Save Changes - Update"><div class="Update" ></div></asp:LinkButton>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TaskInsertTextBox" runat="server" Text='<%# Bind("Task") %>'
TextMode="MultiLine" Rows="1" Font-Bold="true" Width="300px"
/>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ErrorMessage="Please Set Task title"
ControlToValidate="TaskInsertTextBox"
ValidationGroup="myVGInsert"
/>
<asp:LinkButton ID="CancelButton" runat="server"
CommandArgument='<%#Eval("IDTask") %>'
CommandName="Cancel"
CausesValidation="False"><div class="Clear" ></div></asp:LinkButton>
<asp:LinkButton ID="InsertButtonTask" runat="server"
CommandArgument='<%#Eval("IDTask") %>'
CommandName="Insert"
CausesValidation="true"
ValidationGroup="myVGInsert"
><div class="Insert" ></div></asp:LinkButton>
</InsertItemTemplate>
Yes,
set the CausesValidation property to false on the controls you don't want them to trigger the validation.
i have to merge the cells from the cell that does not contain the radio button, to the cell that contains the radio button.
here the link for the interface
http://i839.photobucket.com/albums/zz316/girish_kolte/untitled.jpg
You need to use the TemplateField and here is a tutorial that explains some of the other fields that GridView offers as well.
<asp:GridView ID="gvwAirportSchedule" runat="server">
<Columns>
....
<asp:TemplateField>
<ItemTemplate HeaderText="Airport">
<asp:RadioButton ID="rbAirport" runat="server" Visible='<%# (bool)Eval("IsDestination") %>' />
<asp:Label runat="server" ID="Label1" Text='<%# Eval("Airport") %>' />
</ItemTemplate>
</asp:TemplateField>
....
</Columns>
</asp:GridView>
good answer from David.
One could reduce, by omitting Lable like below
<asp:RadioButton ID="RadioButton1" runat="server" Text='<%# Eval("Airport") %>' />
I have placed an AJAX Tabcontrol on my page.
Inside the TabControl, I also placed a gridview.
<cc1:TabContainer id="tabconLandTransPlan" runat="server" Height="300px" ActiveTabIndex="0" AutoPostBack="True">
<cc1:TabPanel runat="server" ID="tabMasterPlan" HeaderText="Master Plan" >
<HeaderTemplate>
<span style="font-size: 8pt; font-family: Arial">Master Plan</span>
</HeaderTemplate>
<ContentTemplate>
<asp:GridView id="gvBuffer" runat="server" Width="100%" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="Type of Services">
<HeaderStyle Width="26%"></HeaderStyle>
<ItemTemplate>
<asp:Label id="Label1" runat="server" Text='<%# EVAL("code_desc") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Tariff Code">
<HeaderStyle Width="4%" HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# EVAL("res_code") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</cc1:TabPanel>
When I retrieve the gridview, the gridview boundaries extend beyond the Tab Control boundaries. How Can I ensure that the gridview will be just within the boundaries of the tab control? The height of the Gridview is extending beyond the tab control. The width is just fine.
Thanks.
I may have found the answer to this little problem.
Apparently, the ajax tab control follows the size (height) of the controls inside it.
So what I did was set the height of the tabcontrol to Nothing (VB.Net).
Setting it to zero or any other percentage (conversion) values would otherwise throw an error.
Thanks to those who viewed.
Increase the height of the tab control!