I'm trying to set a filter using ajaxtoolkit CascadingDropDown.
The problem is that I need to set a CascadingDropDown using as parent 2 others CascadingDropDown.
My code looks like this:
<asp:DropDownList ID="Parent1" runat="server"/>
<ajaxToolkit:CascadingDropDown ID="CCDParent1" runat="server" TargetControlID="Parent1" ..../>
<asp:DropDownList ID="Parent2" runat="server"/>
<ajaxToolkit:CascadingDropDown ID="CCDParent2" runat="server" ParentControlID="Parent1" TargetControlID="Parent2" ..../>
and this is what I need.
<asp:DropDownList ID="Child" runat="server"/>
<ajaxToolkit:CascadingDropDown ID="CCDChild" runat="server" ParentControlID="Parent1 and Parent2" TargetControlID="Child" ..../>
Is it possible? How?
Thanks
Related
I'm able to update the database fine, but how do I get the current information extracted from the database into the Edit textboxes.
This is my current code:
<asp:ListView ID="ListView1" runat="server" DataSourceID="Details">
<ItemTemplate>
<div class="col-xs-11">
<asp:Label ID="passwordname" runat="server"
Text="Current Password:" />
<asp:Label ID="password" runat="server"
Text='<%# Eval("Password") %>' />
</ItemTemplate>
</asp:ListView>
<asp:TextBox ID="editpassword" runat="server"
placeholder='<%# Eval("Password") %>' Text="New Password">
</asp:TextBox>
How do I get the textbox editpassword to show the current password stored?
Did you try binding the Value of the asp:TextBox?
Also, instead of using Eval(), consider model binding.
<asp:ListView ID="ListView1" runat="server"
DataSourceID="Details" ItemType="MyNamespace.MyClass">
<asp:TextBox ID="editpassword" runat="server"
Value='<%# BindItem.Password %>' Text="New Password">
</asp:TextBox>
Setting up databind for a listview using c#
How can I get separate NamingContainers for different asp:Panel server controls?
In the following .aspx markup, I see that:
<asp:Panel runat="server" ID="Case1" CssClass="caseEvaluationContainer">
<asp:Label ID="NamingContainer1" Text=<%# Case1.NamingContainer.UniqueID %> Runat="server"></asp:Label>
<br />
<asp:Label ID="UniqueID1" Text="<%# Case1.UniqueID %>" Runat="server"></asp:Label>
</asp:Panel>
<asp:Panel runat="server" ID="Case4" CssClass="caseEvaluationContainer">
<asp:Label ID="NamingContainer4" Text=<%# Case1.NamingContainer.UniqueID %> runat="server"></asp:Label>
<br />
<asp:Label ID="UniqueID4" Text="<%# Case1.UniqueID %>" runat="server"></asp:Label>
</asp:Panel>
The UniqueIDs are shown to be different, but not the NamingContainers.
How can I get something like the following to work (I need controls with the same ID's on the page without using a separate databinding containers like asp:Repeater or asp:FormView.
<asp:Panel runat="server" ID="TestPanel1">
<asp:TextBox runat="server" ID="SameControlID"></asp:TextBox>
</asp:Panel>
<asp:Panel runat="server" ID="TestPanel2">
<asp:TextBox runat="server" ID="SameControlID"></asp:TextBox>
</asp:Panel>
You cannot use the same control ID on a Page. Even if these were just HTML DIVs with the same ID you would have a collision.
If you want to handle the code in one manner in the code behind make the contents of your panels into one user control. Then you can drop that one user control in each panel. In that way you can have one set of code to manage the control.
Code sample download.
I need controls with the same ID's on the page
You cannot. It violates the HTML rule.
ID must be document-wide unique.
One of the way that you can achieve by having a same class name of the control with different id like this
<input type="text" id="id1" class="same" />
<input type="text" id="id2" class="same" />
.aspx
<asp:TextBox ID="txtInvite" Width="170px" Height="20px" runat="server"
Font-Size="Small" ></asp:TextBox>
<AjaxToolkit:TextBoxWatermarkExtender ID="tbexInvite"
runat="server" SkinID="skinTextBoxWatermarkExtender"
TargetControlID="txtInvite" WatermarkText="Email"></AjaxToolkit:TextBoxWatermarkExtender>
<asp:RequiredFieldValidator ID="rfvInvite" runat="server"
Display="None" ValidationGroup="Inivitation" SetFocusOnError="true"
ControlToValidate="txtInvite" ErrorMessage="Enter Email."></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="regExpInvite" runat="server"
Display="None" ValidationGroup="Inivitation" SetFocusOnError="true"
ValidationExpression="\s*\w+([-+.]\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*\s*"
ControlToValidate="txtInvite" ErrorMessage="Invalid Email Format."></asp:RegularExpressionValidator>
<div class="ButtonLogin" style="margin-top:-27px;margin-right:143px;_margin-right:105px;">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
<asp:Button ID="btnInvite" runat="server" CssClass="cssLoginButton blue" Text="Invite" ToolTip="Invite" ValidationGroup="Inivitation" CausesValidation="true" onclick="btnInvite_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1" DisplayAfter="0">
<ProgressTemplate>
<asp:Image ID="Image1" ImageUrl="~/App_Themes/Lifetrons/images/progressbar.gif" AlternateText="Processing" runat="server" />
</ProgressTemplate>
</asp:UpdateProgress>
Page_load Code
.CS
this.btnInvite.Attributes.Add("onclick", "this.disabled=true;" + Page.ClientScript.GetPostBackEventReference(this.btnInvite, "").ToString());
I want to disable button after clicking on it with maintaining validation and Onlick method. I refer to this question my problem is same like this question but I haven't solve my problem. How can I solve?
There is no need to mess around with your code-behind Page_Load event. In your button control, just add the following snippet:
OnClientClick="if(Page_ClientValidate('Inivitation')){this.disabled=true;}"
So that your button looks like
<asp:Button ID="btnInvite" runat="server" CssClass="cssLoginButton blue" Text="Invite"
ToolTip="Invite" ValidationGroup="Inivitation" CausesValidation="true"
onclick="btnInvite_Click" OnClientClick="if(Page_ClientValidate('Inivitation')){this.disabled=true;}" />
You should be able to disable the button using the Button_Click method. Make your first line something like this:
Button.Enabled = False;
There is a problem with this method though. If the page loads too quickly or the code freezes it will not disable the button properly. Just remember to re-enable the button at the end of the method if the validation fails or times out.
Another method you may try is to hide it using CSS. I am a big fan of this because it always works and it is very simple. You need a technology like jQuery where you can add classes on the fly. You can use the AddClass and RemoveClass API in jQuery to add/remove CSS classes at runtime. Take a look here. http://jqueryui.com/addClass/
you can use Like this
<asp:Button ID="btnInvite" runat="server" CssClass="cssLoginButton blue" Text="Invite" ToolTip="Invite" ValidationGroup="Inivitation" CausesValidation="true" UseSubmitBehavior = False"onclick="btnInvite_Click" />
Hello Everyone
I have a detailsview, where there are 3 bound fields and a template field.
The template field has a DropDownList, which I have connected to an AccessDataSource.
But when I run, the dropdownlist has just the "System.Data.DataRowView" as it's items.
I wish to get the items from DB to be listed down in DropDownList
This is my code
asp:TemplateField HeaderText="State/Province" SortExpression="State/Province">
<EditItemTemplate>
<asp:DropDownList ID="ddlState" runat="server" DataSourceID="AccessDataSource1"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/App_Data/db1.mdb"
SelectCommand="SELECT [State/Province_name] FROM [State/Province_List ]">
</asp:AccessDataSource>
</EditItemTemplate>
</asp:TemplateField>
Should I add "DataBinding" or "DataBound" event for DropDownList?? to make it perfect?
Help me regarding this issue
Thanks,
Arjun
Define the filed to use in the drop down list
<asp:DropDownList ID="ddlState" runat="server"
DataSourceID="AccessDataSource1"
DataTextField="State/Province_name"
DataValueField="State/Province_name"
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
If you have problems with this non-standard column name, try to use an alias
SELECT [State/Province_name] AS StateProv FROM [State/Province_List ]
(Is the space in [State/Province_List ] OK?)
Then use this one
<asp:DropDownList ID="ddlState" runat="server"
DataSourceID="AccessDataSource1"
DataTextField="StateProv"
DataValueField="StateProv"
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
I want to be able to show the Label next to the manually inserted item "All Profiles", right now it only shows the checkbox at the top but I am not sure how to pass the text to the label.
Thanks
Can you try something like that?
<telerik:radcombobox id="myCombo" emptymessage="All Types" runat="server" width="200px" AppendDataBoundItems="True">
<ItemTemplate>
<div onclick="StopPropagation(event)">
<asp:CheckBox runat="server" ID="chk1" onclick="onCheckBoxClick(this)"/>
<asp:Label runat="server" ID="lblProfile" AssociatedControlID="chk1"><%# Eval("Name") %></asp:Label>
</div>
</ItemTemplate>
<Items>
<telerik:RadComboBoxItem runat="server" Name="Hello"></telerik:RadComboBoxItem>
</Items>
</telerik:radcombobox>
Try databinding again after inserting "All profiles"-item.
If that doesnt work, try something like this:
var values = myDbConnection.GetValues();
var listOfValues = values.Select(x => new ListItem(x.Name, x.Value)).ToList(); // something like that
listOfValues.Add(new ListItem("All Profiles"));
myCombo.DataSource = listOfValues;
myCombo.DataBind();
Telerik recommends to rebind added items in the DataBound event handler like the following
ddlCombobox.Items[0].DataBind()
Check the following links for similar issue on Telerik site
http://www.telerik.com/account/support-tickets/view-ticket.aspx?threadid=327434
http://www.telerik.com/help/aspnet-ajax/combobox-insert-default-item-when-databinding.html