show radiobutonlist in datalist with asp.net - asp.net

I have two dropdownlist and i want when fist and second dropdownlist triger then fill updatepanel_sehiri_izmir_radiolist but i cant create dynamic radiobutonlist.i think use datalist and radiobuton list .but i cant run code
<asp:UpdatePanel ID="UpdatePanel_sehiri_izmir_radiolist" runat="server" ChildrenAsTriggers="True"
UpdateMode="Conditional">
<ContentTemplate>
<asp:DataList ID="DataList_sehiri_izmir_yeni" runat="server" DataSourceID="SqlDataSource_sehir_izmir"
OnItemCommand="DataList_sehiri_izmir_yeni_ItemCommand">
<ItemTemplate>
<asp:RadioButtonList ID="rb_sehiri_izmir" runat="server" AutoPostBack="True" RepeatDirection="Horizontal"
CommandArgument="gonder" RepeatColumns="1" RepeatLayout="Flow" OnSelectedIndexChanged="rb_sehiri_izmir_SelectedIndexChanged">
<asp:ListItem id="TestedYes" runat="server" Value='<%# Eval("imp_id") %>' Text='<%# Eval("imp_id") %>' />
<asp:ListItem id="TestedNo" runat="server" Value="False" Text="No" />
</asp:RadioButtonList>
</ItemTemplate>
</asp:DataList>
<asp:SqlDataSource ID="SqlDataSource_sehir_izmir" runat="server" ConnectionString="<%$ ConnectionStrings:Web_KentrehberiConnectionString %>"
SelectCommand="SELECT * FROM [Important_places]"></asp:SqlDataSource>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="drp_sehiri_izmir_ulke_adi" EventName="SelectedIndexChanged" />
<asp:AsyncPostBackTrigger ControlID="drp_sehiri_izmir_sehir_adi" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>

Related

Ajax for asp.net form view

Inside form view I have drop down list on selected index change I have text box appearing.
Now I want to keep both these drop down and Text box inside Ajax update panel. Upon click button out side update panel I want to save these two fields as well.
Any help Much appreciated.
Here aspx code
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
<br />
<asp:DropDownList ID="ddlLName"
runat="server" ValidationGroup="VG1" SelectedValue='<%# Bind("LNAMEIFYES") %>' OnSelectedIndexChanged="ddlLName_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Value="">Please select...</asp:ListItem>
<asp:ListItem Value="1">Yes</asp:ListItem>
<asp:ListItem Value="2">No</asp:ListItem>
</asp:DropDownList>
<br />
<asp:Panel ID="pnlLNAme" runat="server" Visible="false">
LName:
<asp:TextBox ID="LNameTextBox" runat="server" Text='<%# Bind("LName") %>' />
<br />
</asp:Panel>
Code Behind
protected void ddlLName_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList ddlLName = (DropDownList)FormView1.FindControl("ddlLName");
if (ddlLName.SelectedValue == "1")
{
Panel pnlLNAme = (Panel)FormView1.FindControl("pnlLNAme");
pnlLNAme.Visible = true;
}
else
{
Panel pnlLNAme = (Panel)FormView1.FindControl("pnlLNAme");
pnlLNAme.Visible = false;
}
}
I solved the problem by using by using two update panals, using trigger in one of the update panal.
<EditItemTemplate>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
ID:
<asp:Label ID="IDLabel1" runat="server" Text='<%# Eval("ID") %>' />
<br />
Name:
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
<br />
<asp:DropDownList ID="ddlLName"
runat="server" ValidationGroup="VG1" SelectedValue='<%# Bind("LNAMEIFYES") %>' OnSelectedIndexChanged="ddlLName_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Value="">Please select...</asp:ListItem>
<asp:ListItem Value="1">Yes</asp:ListItem>
<asp:ListItem Value="2">No</asp:ListItem>
</asp:DropDownList>
<br />
<asp:Panel ID="pnlLNAme" runat="server" Visible="false">
LName:
<asp:TextBox ID="LNameTextBox" runat="server" Text='<%# Bind("LName") %>' />
<br />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
Salary:
<asp:TextBox ID="SalaryTextBox" runat="server" Text='<%# Bind("Salary") %>' />
<br />
IsActive:
<asp:CheckBox ID="IsActiveCheckBox" runat="server" Checked='<%# Bind("IsActive") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" />
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="UpdateButton" EventName="Click_Enent" />
</Triggers>
</asp:UpdatePanel>
</EditItemTemplate>

perform validation on multiple buttons

I have two section of elements inside the form (e.g. pizza and burger).
Each section has different fields and each section has its own submit button.
Now I want to validate each of these section only if their corresponding submit button is pressed. If the other submit button is pressed, it should not validate other section of elements.
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Panel ID="Panel2" runat="server" GroupingText="Burger" BackImageUrl="~/finalll/check 24/check 24/images/background-burger.jpg"
Width="684px">
<asp:Label ID="burgertype" runat="server" Text="Burger Type" Width="249px"></asp:Label><br />
<asp:DropDownList ID="DropDownListburger" AppendDataBoundItems="true" runat="server"
OnLoad="DropDownListburger_Load">
<asp:ListItem Text="<Select One>" Value="" />
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidatorbtype" runat="server" InitialValue=""
ControlToValidate="DropDownListburger" ForeColor="Red" ErrorMessage="*"></asp:RequiredFieldValidator>
<br />
<asp:Label ID="burgersize" runat="server" Text="Burger Size" Width="249px"></asp:Label><br />
<asp:DropDownList ID="DropDownbsize" runat="server">
<asp:ListItem Text="Select One" Value=""></asp:ListItem>
<asp:ListItem Text="small" Value="small"></asp:ListItem>
<asp:ListItem Text="medium" Value="medium"></asp:ListItem>
<asp:ListItem Text="large" Value="large"></asp:ListItem>
<asp:ListItem Text="Extra Large" Value="Extra Large"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidatorbsize" runat="server" InitialValue=""
ControlToValidate="DropDownbsize" ForeColor="Red" ErrorMessage="*"></asp:RequiredFieldValidator>
<br />
<asp:Label ID="Labelquantity2" runat="server" Text="Quantity" Width="249px"></asp:Label><br />
<asp:TextBox ID="TextBoxquantity2" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidatorquanty2" runat="server" Text="*"
ControlToValidate="TextBoxquantity2" ForeColor="Red"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidatorquanty2" runat="server"
ErrorMessage="Enter Valid Quantity" ControlToValidate="TextBoxquantity2" CssClass="requiredFieldValidateStyle"
ForeColor="Red" ValidationExpression="[0-9]+">
</asp:RegularExpressionValidator>
<br />
<asp:Button ID="Buttonburger" runat="server" Text="submit" OnClick="Buttonburger_Click" />
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Buttonburger" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="Panel1" runat="server" GroupingText="Pizza" BackImageUrl="~/finalll/check 24/check 24/images/1380310811-pitstsa-ch1--39.jpg"
Width="684px">
<asp:Label ID="Pizzatype" Text="Pizza Type" runat="server"></asp:Label>
<br />
<asp:DropDownList ID="dropdwnpizza" AppendDataBoundItems="true" runat="server" OnLoad="dropdwnpizza_Load">
<asp:ListItem Text="<Select One>" Value="" />
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfqdropdwnpizza" runat="server" InitialValue="" ControlToValidate="dropdwnpizza"
ForeColor="Red" ErrorMessage="*"></asp:RequiredFieldValidator>
<br />
<asp:Label ID="pizzasize" Text="Pizza Size" runat="server"></asp:Label><br />
<asp:DropDownList ID="DropDwnsize" runat="server">
<asp:ListItem Text="Select One" Selected="True" Value=""></asp:ListItem>
<asp:ListItem Text="small" Value="small"></asp:ListItem>
<asp:ListItem Text="medium" Value="medium"></asp:ListItem>
<asp:ListItem Text="large" Value="large"></asp:ListItem>
<asp:ListItem Text="Extra Large" Value="Extra Large"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfqpizzasize" runat="server" InitialValue="" ControlToValidate="DropDwnsize"
ForeColor="Red" ErrorMessage="*"></asp:RequiredFieldValidator>
<br />
<asp:Label ID="Labelquantity" runat="server" Text="Quantity" Width="249px"></asp:Label><br />
<asp:TextBox ID="TextBoxquantity" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="pprc" runat="server" Text="*" ControlToValidate="TextBoxquantity"
ForeColor="Red"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidatorpprc" runat="server"
ErrorMessage="Enter Valid Quantity" ControlToValidate="TextBoxquantity" CssClass="requiredFieldValidateStyle"
ForeColor="Red" ValidationExpression="[0-9]+">
</asp:RegularExpressionValidator>
<asp:Button ID="Buttonpizza" runat="server" Text="submit" OnClick="Buttonpizza_Click" />
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Buttonpizza" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
You need to use Validation Groups, from MSDN -
Validation groups allow you to organize validation controls on a page
as a set. Each validation group can perform validation independently
from other validation groups on the page.
For example (from MSDN):
<asp:requiredfieldvalidator id="RequiredFieldValidator2"
controltovalidate="AgeTextBox"
validationgroup="PersonalInfoGroup"
errormessage="Enter your age."
runat="Server">
</asp:requiredfieldvalidator>
<!--When Button1 is clicked, only validation controls that are a part of PersonalInfoGroup
are validated.-->
<asp:button id="Button1"
text="Validate"
causesvalidation="true"
validationgroup="PersonalInfoGroup"
runat="Server" />

Ajax UpdatePanel not firing?

I am not understanding why this doesn't fire. It will not even call the event. Any thoughts? Really what I want to do, is prevent a full post-back. The page is large and each time it does a post back it jumps to the top.
<asp:UpdatePanel runat="server" id="UpdatePanel" updatemode="Conditional">
<ContentTemplate>
<p>
<asp:Label runat="server" ID="lblSnippet" AssociatedControlID="cmbSnippet">
From snippet:
</asp:Label>
<asp:DropDownList runat="server" ID="cmbSnippet" CssClass="dropdown" AutoPostBack="true">
<asp:ListItem>
None
</asp:ListItem>
<asp:ListItem>
Read Part
</asp:ListItem>
<asp:ListItem>
Read Feed
</asp:ListItem>
</asp:DropDownList>
</p>
<!--Code-->
<p>
<asp:Label runat="server" ID="lblCode" AssociatedControlID="txtCode">
From code:
</asp:Label>
<asp:TextBox runat="server" ID="txtCode" TextMode="MultiLine" CssClass="editor" MaxLength="100" Height="200" Wrap="false" />
</p>
</ContentTemplate>
<Triggers>
<asp:Asyncpostbacktrigger controlid="cmbSnippet" eventname="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
you have not declared the event
something like this:
<asp:DropDownList runat="server" ID="cmbSnippet" CssClass="dropdown" AutoPostBack="true" OnSelectedIndexChanged="cmbSnippet_SelectedIndexChanged">
and his relative handler in codebehind...

modal popup extender not showing panel on button click

I'm trying to use a modal popup extender on my page so when I click a button, it must show a panel. Here is what I have:
<asp:UpdatePanel runat="server" ID="updPanel">
<ContentTemplate>
<ajaxToolkit:ModalPopupExtender ID="mpeEmailComplete" runat="server" TargetControlID="btnTesting"
PopupControlID="pnl" OkControlID="btnOk"
BackgroundCssClass="modalBackground">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="pnl" runat="server" style="display:none;">
<asp:UpdatePanel ID="udp" runat="server">
<ContentTemplate>
<asp:Panel runat="server" ID="pnlEmailComplete" Visible="false">
<asp:Label runat="server" ID="lblTest" Text="Testing testing testing"></asp:Label>
<asp:Button runat="server" ID="btnOk" Text="OK" />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
<asp:Button runat="server" ID="btnTesting" Text="Testing"/>
</ContentTemplate>
</asp:UpdatePanel>
but i can't get the panel to popup when the button is clicked. Anybody know why?
Your innermost panel has Visible=false.
<asp:Panel runat="server" ID="pnlEmailComplete" Visible="false"> *(change here)*
So, when you press the TESTING button, the ModalPopupExtender correctly causes the outer panel to display, but it's displaying an invisible inner panel, hence you see nothing on screen.
<asp:Panel ID="pnl" runat="server" style="display:none;"> *(this is ok)*
To fix, just yank the Visible=false from the outer panel (pnlEmailComplete)
Hope that helps!
Do you have any JavaScript errors and is pnl.Visible=False; set on the server-side anywhere?
Make sure you have the AjaxControlToolkit referenced properly, NuGet is the easiest way to add the reference.
http://nuget.org/packages/ajaxcontroltoolkit
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Btnshow" runat="server" Text="Show" OnClick="Btnshow_Click" />
<asp:Button ID="BtnTarget" runat="server" Text="Target" Style="display: none" />
<asp:TextBox ID="TextBox1" runat="server">
</asp:TextBox>
<input type="button" value="Get" onclick="abc()" />
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="BtnTarget"
PopupControlID="Panel1">
</asp:ModalPopupExtender>
<asp:Panel ID="Panel1" runat="server" BackColor="Black" Width="300px" Height="300px">
<asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="BtnHide" runat="server" Text="Hide Button" OnClick="BtnHide_Click" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="BtnHide" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Btnshow" EventName="Click" />
</Triggers>
</asp:UpdatePanel>

Trigger asp:UpdatePanel from button

I've got a table which i want to update with a button, the table is within a "li" tag, and the button is in another. Here's my code:
<li runat="server">
<asp:DropDownList ID="cYear" runat="server" Width="100%" Font-Size="Large">
<asp:ListItem>2011</asp:ListItem>
...
</asp:DropDownList>
<asp:DropDownList ID="cMonth" runat="server" Width="100%" Font-Size="Large">
<asp:ListItem>1</asp:ListItem>
...
</asp:DropDownList>
<asp:DropDownList ID="cDay" runat="server" Width="100%" Font-Size="Large">
<asp:ListItem>1</asp:ListItem>
...
</asp:DropDownList>
<asp:TextBox ID="cNum" runat="server"></asp:TextBox>
<asp:Button ID="cEvent" onclick="cEvent_Click" CausesValidation="false"/>
</li>
<li runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel id = "updatePanel1" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="cEvent"/>
</Triggers>
<ContentTemplate>
...
</ContentTemplate>
</asp:UpdatePanel>
</li>
The Site is in Hebew so just ignore the wired string, the button Id is cEvent, and i want it to update the updatePanel, but instead it just doing nothing....

Resources