It depends on the ID of your drop down and your markup in general. Would you mind posting some of your rendered HTML for your details view and / or your drop down?
function stopPostback() {
//logic goes here
alert("From javascript");
if (logic is false)
return true; //true will stop post back
else
return false; //false will allow post back
}
hr3
Member
15 Points
32 Posts
Find control in details view using jQuery
Jan 17, 2013 01:32 AM|LINK
I am trying to find the selected value of drop down list in the insert template of my details view. How can I do that using jQuery?
Rion William...
All-Star
26960 Points
4465 Posts
Re: Find control in details view using jQuery
Jan 17, 2013 01:35 AM|LINK
BrockAllen
All-Star
27512 Points
4895 Posts
MVP
Re: Find control in details view using jQuery
Jan 17, 2013 01:37 AM|LINK
$("#theIdOfYourDropDown").val()
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
hr3
Member
15 Points
32 Posts
Re: Find control in details view using jQuery
Jan 17, 2013 01:42 AM|LINK
Here is my rendered markup for my drop down list:
Rion William...
All-Star
26960 Points
4465 Posts
Re: Find control in details view using jQuery
Jan 17, 2013 01:46 AM|LINK
You can use the following to get your selected value :
$("#MainContent_detlView_ddlList :selected").val()Example
hr3
Member
15 Points
32 Posts
Re: Find control in details view using jQuery
Jan 17, 2013 01:57 AM|LINK
That works great. But, my java script is firing twice:
<asp:DropDownList ID="ddlList" runat="server" AutoPostBack="true" CssClass="dropdown" DataSourceID="entityDataSource" DataTextField="Column1" DataValueField="Column2" onchange="if (stopPostback()) return false;" OnSelectedIndexChanged="ddlList_SelectedIndexChanged"> <asp:ListItem Text="--Select One--" Value="0" Selected="True"></asp:ListItem> </asp:DropDownList>function stopPostback() { //logic goes here alert("From javascript"); if (logic is false) return true; //true will stop post back else return false; //false will allow post back }Am I missing some thing here.