How to add RequiredFieldValidator on a Ajax Editor C# - c#

I am trying to add validation on Editor but it cants work. here is my code
when I run this and fill field its give me an error.
<section style="padding-top: 120px" class="info-area pb-120 container-fluid">
<div class="container-fluid">
<div class="row align-items-center">
<div class="col-lg-12 no-padding info-area-left">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div class="form-horizontal" runat="server" id="FormControls">
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Your Name</label>
<div class="col-sm-10">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtUserName" ForeColor="Red" Display="Dynamic" ValidationGroup="inq" ErrorMessage="Enter name"></asp:RequiredFieldValidator>
<asp:TextBox ID="txtUserName" CssClass="form-control text-uppercase" runat="server" placeholder="Your name"></asp:TextBox>
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Your Testimonial</label>
<div class="col-sm-10">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="Editor1" ForeColor="Red" Display="Dynamic" ValidationGroup="inq" ErrorMessage="Enter Testimonial"></asp:RequiredFieldValidator>
<cc1:Editor ID="Editor1" runat="server" placeholder="Testimonial" />
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<asp:Button ID="btnSend" OnClick="btnSend_Click" CssClass="primary-btn text-uppercase" ValidationGroup="inq" runat="server" Text="Send" />
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</div>
</section>
may helps you

Related

UpdateProgress not firing on every PostBack of controls inside UpdatePanel

I have an UpdatePanel:
<asp:UpdatePanel runat="server" ID="panelFatt">
<ContentTemplate>
<div class="row" runat="server" id="divCFPIva">
<div class="col-md-6">
<div class="form-group">
<label for="txtCF">Codice Fiscale</label>
<asp:TextBox runat="server" ID="txtCF" type="text" MaxLength="16" class="form-control" />
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="txtPIVA">Partita IVA</label>
<asp:TextBox runat="server" ID="txtPIVA" type="text" MaxLength="11" class="form-control" />
</div>
</div>
<div class="col-md-12">
<span class="help-inline hidden lblerror" runat="server" id="lblErrorCFPIva"></span>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group" runat="server" id="divEmail">
<label for="txtEmail" class="control-label">Email*</label>
<div class="controls">
<asp:TextBox runat="server" TextMode="Email" type="text" ID="txtEmail" class="form-control" />
<span class="help-inline hidden lblerror" runat="server" id="lblErrorEmail"></span>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group" runat="server" id="divTelefono">
<label for="txtTelefono" class="control-label">Recapito Telefonico*</label>
<div class="controls">
<asp:TextBox runat="server" ID="txtTelefono" type="text" TextMode="Phone" class="form-control" />
<span class="help-inline hidden lblerror" runat="server" id="lblErrorTelefono"></span>
</div>
</div>
</div>
</div>
<!-- /Row -->
<div class="form-group">
<asp:RadioButton runat="server" ID="radioScegliIndirizziFatt" Text=" Scegli tra uno dei tuoi indirizzi" AutoPostBack="true" OnCheckedChanged="radioScegliIndirizziFatt_CheckedChanged" Checked="true" GroupName="radioIndirizziFatt" />
<div class="form-group" runat="server" id="divScegliIndirizzoFatt">
<asp:DropDownList runat="server" ID="ddlIndirizziFatt" class="form-control"></asp:DropDownList>
<span class="help-inline hidden lblerror" runat="server" id="lblErrorScegliIndirizziFatt"></span>
</div>
<br />
<asp:RadioButton runat="server" ID="radioNuovoIndirizzoFatt" Text=" Inserisci un nuovo Indirizzo" AutoPostBack="true" OnCheckedChanged="radioNuovoIndirizzoFatt_CheckedChanged" GroupName="radioIndirizziFatt" />
<div class="form-group" runat="server" id="divNomeFatt">
<label for="txtNomeFatt" class="control-label">Nome o Ragione Sociale*</label>
<div class="controls">
<asp:TextBox runat="server" ID="txtNomeFatt" type="text" class="form-control" />
<span class="help-inline hidden lblerror" runat="server" id="lblErrorNomeFatt"></span>
</div>
</div>
<div class="form-group" runat="server" id="divIndirizzoFatt">
<label for="txtIndirizzoFatt" class="control-label">Indirizzo*</label>
<div class="controls">
<asp:TextBox runat="server" ID="txtIndirizzoFatt" type="text" class="form-control" />
<span class="help-inline hidden lblerror" runat="server" id="lblErrorIndirizzoFatt"></span>
</div>
</div>
<div class="row">
<div class="col-md-5">
<div class="form-group" runat="server" id="divStatoFatt">
<label for="ddlStatoFatt" class="control-label">Stato</label>
<div class="controls">
<asp:DropDownList runat="server" ID="ddlStatoFatt" OnSelectedIndexChanged="ddlStatoFatt_SelectedIndexChanged" class="form-control" AutoPostBack="true" />
</div>
</div>
</div>
<div class="col-md-7">
<div class="form-group" runat="server" id="divProvinciaFatt" visible="false">
<label runat="server" id="lblProvinciaFatt" for="ddlProvinciaFatt" class="control-label">Provincia</label>
<div class="controls">
<asp:DropDownList runat="server" ID="ddlProvinciaFatt" class="form-control" OnSelectedIndexChanged="ddlProvinciaFatt_SelectedIndexChanged" AutoPostBack="true" />
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-8" runat="server" id="divCittaFatt">
<div class="form-group">
<label runat="server" id="lblCittaFatt" for="txtCittaFatt" class="control-label">Città*</label>
<div class="form-group" runat="server" id="divDDLFatt" visible="false">
<asp:DropDownList runat="server" ID="ddlCittaFatt" class="form-control" OnSelectedIndexChanged="ddlCittaFatt_SelectedIndexChanged" AutoPostBack="true" />
</div>
<br />
<div class="form-group" runat="server" id="divTXTFatt" visible="false">
<asp:TextBox runat="server" ID="txtCittaFatt" type="text" class="form-control" />
</div>
<span class="help-inline hidden lblerror" runat="server" id="lblErrorCittaFatt"></span>
</div>
</div>
<div class="col-md-4" runat="server" id="divCAPFatt">
<div class="form-group">
<label for="txtCAPFatt" class="control-label">CAP*</label>
<div class="controls">
<asp:TextBox runat="server" ID="txtCapFatt" type="text" class="form-control" />
<span class="help-inline hidden lblerror" runat="server" id="lblErrorCAPFatt"></span>
</div>
</div>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
And I'm trying to fire an UpdateProgress that I would like show loading image at every post back of the controls inside the UpdatePanel.
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="panelFatt">
<ProgressTemplate>
<div class="modal">
<div class="center">
<img alt="" src="http://i.stack.imgur.com/FhHRx.gif" />
</div>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
This is not working at all.
I saw on the Internet that someone associates a client method with the click of a button in the Update Panel.
But I should do it for all the controls that make a post back within my update panel.
Is there a way to make it work?
I modified my code in this way:
<asp:UpdatePanel runat="server" ID="panelFatt" UpdateMode="Conditional">
<ContentTemplate>
<div class="row">
<div class="col-md-6">
<h4>
<asp:CheckBox runat="server" ID="checkFattura" Text="Desidero ricevere la Fattura" AutoPostBack="true" OnCheckedChanged="checkFattura_CheckedChanged" CssClass="checkbox-inline cssRadio" /></h4>
</div>
</div>
<br />
<div class="row" runat="server" id="divCFPIva">
<div class="col-md-6">
<div class="form-group">
<label for="txtCF" runat="server" id="lblCF" visible="false">Codice Fiscale</label>
<asp:TextBox runat="server" ID="txtCF" type="text" MaxLength="16" class="form-control" Visible="false" />
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="txtPIVA" runat="server" id="lblPIva" visible="false">Partita IVA</label>
<asp:TextBox runat="server" ID="txtPIVA" type="text" MaxLength="11" class="form-control" Visible="false" />
</div>
</div>
<div class="col-md-12">
<span class="help-inline hidden lblerror" runat="server" id="lblErrorCFPIva"></span>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group" runat="server" id="divEmail">
<label for="txtEmail" class="control-label">Email*</label>
<div class="controls">
<asp:TextBox runat="server" TextMode="Email" type="text" ID="txtEmail" class="form-control" />
<span class="help-inline hidden lblerror" runat="server" id="lblErrorEmail"></span>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group" runat="server" id="divTelefono">
<label for="txtTelefono" class="control-label">Recapito Telefonico*</label>
<div class="controls">
<asp:TextBox runat="server" ID="txtTelefono" type="text" TextMode="Phone" class="form-control" />
<span class="help-inline hidden lblerror" runat="server" id="lblErrorTelefono"></span>
</div>
</div>
</div>
</div>
<!-- /Row -->
<div class="form-group">
<div runat="server" id="divNotVisibleFatt">
<asp:RadioButton runat="server" ID="radioScegliIndirizziFatt" Text=" Scegli tra uno dei tuoi indirizzi" AutoPostBack="true" OnCheckedChanged="radioScegliIndirizziFatt_CheckedChanged" Checked="true" GroupName="radioIndirizziFatt" />
<div class="form-group" runat="server" id="divScegliIndirizzoFatt">
<asp:DropDownList runat="server" ID="ddlIndirizziFatt" class="form-control"></asp:DropDownList>
<span class="help-inline hidden lblerror" runat="server" id="lblErrorScegliIndirizziFatt"></span>
</div>
<br />
<asp:RadioButton runat="server" ID="radioNuovoIndirizzoFatt" Text=" Inserisci un nuovo Indirizzo" AutoPostBack="true" OnCheckedChanged="radioNuovoIndirizzoFatt_CheckedChanged" GroupName="radioIndirizziFatt" />
</div>
<div class="form-group" runat="server" id="divNomeFatt">
<label for="txtNomeFatt" class="control-label">Nome o Ragione Sociale*</label>
<div class="controls">
<asp:TextBox runat="server" ID="txtNomeFatt" type="text" class="form-control" />
<span class="help-inline hidden lblerror" runat="server" id="lblErrorNomeFatt"></span>
</div>
</div>
<div class="form-group" runat="server" id="divIndirizzoFatt">
<label for="txtIndirizzoFatt" class="control-label">Indirizzo*</label>
<div class="controls">
<asp:TextBox runat="server" ID="txtIndirizzoFatt" type="text" class="form-control" />
<span class="help-inline hidden lblerror" runat="server" id="lblErrorIndirizzoFatt"></span>
</div>
</div>
<div class="row">
<div class="col-md-5">
<div class="form-group" runat="server" id="divStatoFatt">
<label for="ddlStatoFatt" class="control-label">Stato</label>
<div class="controls">
<asp:DropDownList runat="server" ID="ddlStatoFatt" OnSelectedIndexChanged="ddlStatoFatt_SelectedIndexChanged" class="form-control" AutoPostBack="true" />
</div>
</div>
</div>
<div class="col-md-7">
<div class="form-group" runat="server" id="divProvinciaFatt" visible="false">
<label runat="server" id="lblProvinciaFatt" for="ddlProvinciaFatt" class="control-label">Provincia</label>
<div class="controls">
<asp:DropDownList runat="server" ID="ddlProvinciaFatt" class="form-control" OnSelectedIndexChanged="ddlProvinciaFatt_SelectedIndexChanged" AutoPostBack="true" />
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-8" runat="server" id="divCittaFatt">
<div class="form-group">
<label runat="server" id="lblCittaFatt" for="txtCittaFatt" class="control-label">Città*</label>
<div class="form-group" runat="server" id="divDDLFatt" visible="false">
<asp:DropDownList runat="server" ID="ddlCittaFatt" class="form-control" OnSelectedIndexChanged="ddlCittaFatt_SelectedIndexChanged" AutoPostBack="true" />
</div>
<br />
<div class="form-group" runat="server" id="divTXTFatt" visible="false">
<asp:TextBox runat="server" ID="txtCittaFatt" type="text" class="form-control" />
</div>
<span class="help-inline hidden lblerror" runat="server" id="lblErrorCittaFatt"></span>
</div>
</div>
<div class="col-md-4" runat="server" id="divCAPFatt">
<div class="form-group">
<label for="txtCAPFatt" class="control-label">CAP*</label>
<div class="controls">
<asp:TextBox runat="server" ID="txtCapFatt" type="text" class="form-control" />
<span class="help-inline hidden lblerror" runat="server" id="lblErrorCAPFatt"></span>
</div>
</div>
</div>
</div>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="checkFattura" EventName="CheckedChanged"/>
<asp:AsyncPostBackTrigger ControlID="radioScegliIndirizziFatt" EventName="CheckedChanged"/>
<asp:AsyncPostBackTrigger ControlID="radioNuovoIndirizzoFatt" EventName="CheckedChanged"/>
<asp:AsyncPostBackTrigger ControlID="ddlStatoFatt" EventName="SelectedIndexChanged"/>
<asp:AsyncPostBackTrigger ControlID="ddlProvinciaFatt" EventName="SelectedIndexChanged"/>
<asp:AsyncPostBackTrigger ControlID="ddlCittaFatt" EventName="SelectedIndexChanged"/>
</Triggers>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="panelFatt">
<ProgressTemplate>
<div class="modal">
<div class="center">
<img alt="" src="https://i.stack.imgur.com/FhHRx.gif" />
</div>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
but even not working..
and my data bind aer in Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// Combo Province
DataTable dtProv = oTabelle.GetDTProvinceByIdStato(IdStatoITA);
oUty.loadDDL(ref ddlProvinciaFatt, dtProv, "IdProvincia", "NomeProvincia", "", "", "");
ddlProvinciaFatt.SelectedValue = "";
...
}
}
and my associated event is the following
protected void ddlProvinciaFatt_SelectedIndexChanged(object sender, EventArgs e)
{
txtCapFatt.Text = "";
string idProvincia = ddlProvinciaFatt.SelectedValue;
// carico i comuni della provincia
oUty.loadDDL(ref ddlCittaFatt, oTabelle.GetDTComuniByIdProvincia(idProvincia), "IdComune", "NomeComune", "", "", "", true);
ddlCittaFatt.SelectedIndex = -1;
}
where I'm wrong?
For displaying UpdateProgress on every PostBack of your Controls in UpdatePanel:
Set UpdateMode of your UpdatePanel to Conditional:
Manually trigger AsyncPostBackTrigger to your controls inside UpdatePanel and give the ControlID and EventName that will fire:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" >
</ContentTemplate>
<!-- Some other controls that perform post back -->
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlStatoFatt"
EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
And can test its working in events using System.Threading.Thread.Sleep(3000);:
protected void ddlStatoFatt_SelectedIndexChanged(object sender, EventArgs e)
{
// delay it for testing
System.Threading.Thread.Sleep(3000);
Label1.Text = "Page refreshed with DropDownList at " +
DateTime.Now.ToString();
}
I have tried this at my site and its working:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" >
<ContentTemplate>
<fieldset>
<legend>UpdatePanel1</legend>
<asp:Label ID="Label1" runat="server" Text="Panel initially rendered."></asp:Label>
<br />
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Value="1">Choose</asp:ListItem>
<asp:ListItem Value="2">Blue</asp:ListItem>
<asp:ListItem Value="3">Green</asp:ListItem>
</asp:DropDownList>
<br />
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
</fieldset>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="SelectedIndexChanged" />
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
Panel2 updating....
</ProgressTemplate>
</asp:UpdateProgress>
And Code-Behind:
protected void Button1_Click(object sender, EventArgs e)
{
// Introducing delay for demonstration.
System.Threading.Thread.Sleep(3000);
Label1.Text = "Page refreshed at " +
DateTime.Now.ToString();
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
// Introducing delay for demonstration.
System.Threading.Thread.Sleep(3000);
Label1.Text = "Page refreshed with DDL at " +
DateTime.Now.ToString();
}
I used code below in my projects and worked properly. I hope it helps you.
<asp:UpdatePanel ID="panelFatt" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:UpdateProgress ID="UpdateProgress1" runat="Server" DisplayAfter="1" AssociatedUpdatePanelID="panelFatt">
<ProgressTemplate>
<div style="position: absolute; text-align: center; height: 100%; width: 100%; top: 0; right: 0; left: 0; z-index: 9999999; background-color: #000000; opacity: 0.7;">
<image src="http://i.stack.imgur.com/FhHRx.gif" alternatetext="Loading ..." tooltip="Loading ..." style="padding: 10px; position: absolute; top: 45%; left: 50%;" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</ContentTemplate>
</asp:UpdatePanel>
From the Code you provided , everything seems fine but you have missed to add the AsyncPostback trigger in your <asp:updatepanel></asp:updatepanel> : for your case , this can be added:
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlStatoFatt"
EventName="SelectedIndexChanged" />
</Triggers>
I have added only on dropdown , to check whether its working or not , if it goes well then you can change the controlID with your updatepannelId.
Another thing you missed in your code is that you need to see the UpdateMode="Conditional" in your update panel
If you need to show it for fullpostbacks you can use a simple javascript function. Taken from, https://forums.asp.net/t/1101546.aspx?Update+Progress+show+on+Ajax+Full+Postback+Trigger
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="upTest">
<ProgressTemplate>
Updating!
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="upTest" ChildrenAsTriggers="False" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:Button ID="btnFullPost" Text="Full Post" runat="server" OnClick="btnFullPost_Click" OnClientClick="ShowProgress();"/>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnFullPost" />
</Triggers>
</asp:UpdatePanel>
<script type="text/javascript">
function ShowProgress()
{
document.getElementById('<% Response.Write(UpdateProgress1.ClientID); %>').style.display = "inline";
}
</script>

Add asp.net update panel linkbutton not working

In my webapplication page ,top of the page contain seven linkbutton .So i am adding asp.net update panel .After including that the linkbutton events are not worked.Without using the update panel it work well. How can I solve the problem?
Here is my code:
<div class="container">
<asp:UpdatePanel runat="server" ID="up1" UpdateMode="Conditional"><ContentTemplate>
<div class="col-md-12" data-wow-delay="0s">
<div class="filter_menu ">
<div class="boltsort">Sort By:</div>
<div class="boltsortlist">
<asp:LinkButton ID="lkrecomm" runat="server">Recommended</asp:LinkButton> |
<asp:LinkButton ID="lkrating" runat="server">User Rating</asp:LinkButton> |
<asp:LinkButton ID="lkprice" runat="server" OnClick="lkprice_Click">Price</asp:LinkButton> |
<asp:LinkButton ID="lkDistance" runat="server" OnClick="lkDistance_Click">Distance</asp:LinkButton> |
<asp:LinkButton ID="lkA_Z" runat="server" OnClick="lkA_Z_Click" Text="A-Z"></asp:LinkButton> |
<asp:LinkButton ID="lkNewest" runat="server" OnClick="lkNewest_Click">Newest</asp:LinkButton> |
<asp:LinkButton ID="lkHalal" runat="server" OnClick="lkHalal_Click">Halal</asp:LinkButton>
</div>
</div>
</div>
</ContentTemplate></asp:UpdatePanel>
<div class="col-md-12">
<div class="left_side_choose_list">
<div class="select_rest">
<p class="left_span">Choose Multi / Restaurant</p>
<div id="dl-menu" class="dl-menuwrapper">
<div class="top_arrow dl-trigger"><i class="glyphicon glyphicon-chevron-right"></i></div>
<div class="menu_list dl-menu">
<div class="all_menu text-left">Available Restaurant near you..</div>
<div class="panel-group null_margin" id="accordion">
<asp:ListView ID="LvCuisine" runat="server" OnItemDataBound="OnItemDataBound">
<ItemTemplate>
<div class="accoring panel-default">
<div class="accor_styles text-left">
<a class="accordion-toggle panel-title" data-toggle="collapse-next" data-parent=".accoring">
<asp:HiddenField ID="hdCuisineID" runat="server" Value='<%# Eval("ID") %>' />
<asp:CheckBox runat="server" Text='<%# Eval("CuisineName")%>' CssClass="ui-checkboxcuisine" ID="chk11" />
</a>
</div>
<div class="panel-collapse collapse">
<div class="panel-body padd_null text-left">
<div class="driving-license-kind">
<asp:Repeater ID="RptItems" runat="server">
<ItemTemplate>
<div class="checkbox_accor">
<div id="chkdiv">
<asp:HiddenField ID="hdRID" runat="server" Value='<%# Eval("RID") %>' />
<asp:CheckBox runat="server" Text='<%# Eval("RestaurantTitle")%>' CssClass="ui-checkbox " />
</div>
</div>
</ItemTemplate></asp:Repeater>
</div>
</div>
</div>
</div>
</ItemTemplate></asp:ListView>
<asp:Button ID="btndone" runat="server" class="btn accor_btn pull-right test" Text="Done" OnClick="btndone_Click" />
</div>
</div>
</div>
</div>
</div>
<div class="row ">
<div class="col-md-12 col-sm-12 col-xs-12" data-wow-delay="0s">
<asp:ListView ID="lvRestaurants" runat="server" OnItemCommand="lvRestaurants_ItemCommand">
<ItemTemplate>
<div class="a_brandstore_details12 ">
<div class="a_pro_inner">
<div class="a_brand_logo">
<asp:Image runat="server" ID="Image2" Width="133px" Height="113px" ImageUrl='<%# Eval("ImagePath")%>' /></div>
<div class="a_details fix_width">
<div class="a_name">
<asp:Label ID="lbl_Resttitle" runat="server" Text='<%# Eval("RestaurantTitle")%>'></asp:Label></div>
<div class="a_address123">
<div class="a_brad_food">
<asp:Label ID="lbl_Cuisines" runat="server" Text='<%# Eval("CuisineName")%>'></asp:Label></div>
<div class="a_order_rating">
<img src="/CustomerPortalTemplate/images/rating.jpg"></div>
</div>
</div>
<div class="brand_details">
<div class="a_address123">
<div class="a_brad_open">
Open at :
<asp:Label Text='<%# Eval("OpenTime") %>' runat="server" />
</div>
<div class="a_deli_time">Delivery Fee : $ 1.0</div>
<div class="a_order">Minimum Order :
<asp:Label Text='<%# Eval("MinimumOrder") %>' runat="server" /></div>
<div class="avilable_range">
<div class="icons_place"><asp:Image ImageUrl='<%# (bool)Eval("WirelessFacility")==true ? "/CustomerPortalTemplate/img/wi-fi.png" : "/CustomerPortalTemplate/img/wi-fi_r.png" %>' runat="server"/></div>
<div class="icons_place"><asp:Image ImageUrl='<%# (bool)Eval("ParkingFacility")==true ? "/CustomerPortalTemplate/img/parking.png" : "/CustomerPortalTemplate/img/parking_r.png" %>' runat="server" /></div>
<div class="icons_place"><asp:Image ImageUrl='<%# (bool)Eval("DisableAccess")==true ? "/CustomerPortalTemplate/img/disabled.png" : "/CustomerPortalTemplate/img/disabled_r.png" %>' runat="server" /></div>
</div>
<asp:Label ID="lbldist" runat="server" Text='<%# Eval("Distance")%>' Visible="false"></asp:Label>
</div>
</div>
<div class="bottom_buttons">
<div class="button_div text-left fix_width ">
<input type="button" value="Group Order" class="btn restaurant_btn ">
</div>
<div class="button_div text-left padd_left_50">
<input type="button" value="Book Table" class="btn restaurant_btn ">
</div>
<div class="button_div text-left">
<asp:Button ID="btnorder" class="btn restaurant_btn" Text='<%# Eval("BUTTONNAME")%>' CommandArgument='<%#Eval("ID")+ ","+Eval("RestaurantTitle") %>' CommandName="OrderRestId" runat="server"></asp:Button>
</div>
</div>
<div class="a_brand_offer123 hidden-390" style="background: url(/CustomerPortalTemplate/images/offer-bg.png) no-repeat">
<span class="offer">20%</span><br />
<span class="offer">OFF</span>
</div>
</div>
</div>
</ItemTemplate>
</asp:ListView>
</div>
</div>
</div>
</div>

Page content disappear after timer ticks

I am using UpdatePanel control to update charts on my page after a certain time. I faced a problem that when the timer ticks, all charts disappear. I traced and found nothing error. Can anyone help me on this?
Here is a sample of the .aspx file
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager>
<asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick" Interval="120000">
</asp:Timer>
<div class="row">
<div class="col-lg-4 col-md-4">
<asp:DropDownList ID="ddlDuration" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlDuration_SelectedIndexChanged" CssClass="form-control" Style="margin-left: 5px;">
<asp:ListItem Value="1">Today</asp:ListItem>
<asp:ListItem Value="3">A week ago</asp:ListItem>
<asp:ListItem Value="2">A month ago</asp:ListItem>
<asp:ListItem Value="4">A year ago</asp:ListItem>
</asp:DropDownList>
</div>
<div class="col-lg-8 col-md-8">
<div class="col-lg-1 col-md-1">
<label class="control-label">From Date:</label>
</div>
<div class="col-lg-3 col-md-3">
<asp:TextBox ID="txtDateFrom" runat="server" CssClass="form-control"></asp:TextBox>
</div>
<div class="col-lg-1 col-md-1">
<label class="control-label">To Date:</label>
</div>
<div class="col-lg-3 col-md-3">
<asp:TextBox ID="txtDateTo" runat="server" CssClass="form-control"></asp:TextBox>
</div>
<asp:Button ID="btnGetReport" runat="server" Text="Apply" CssClass="btn btn-success" Style="background-color: #8B0000; border: #8B0000;" OnClick="btGetReport_Click"></asp:Button>
<div class="row">
<asp:Label ID="dterror" runat="server" />
</div>
<hr />
<div id="chart">
<div class="row">
<div class="col-md-6">
<div class="panel panel-primary">
<div class="panel-body">
<div id="ComplaintsByStatus">
</div>
</div>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
and here is part of the code behind
protected void Timer1_Tick(object sender, EventArgs e)
{
UpdateChart();
}
here is a screen shot of what I get before timer ticks
and this is what I get after
Thanks in advance.

Bootstrap modal's button ASP.NET C#

I have a problem with my site
I have this modal:
<div class="modal fade " id="loginModal" tabindex="-1" role="dialog" aria-labelledby="loginModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content login-modal">
<div class="modal-header login-modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title text-center" id="loginModalLabel">Autenticazione utente</h4>
</div>
<div class="modal-body">
<div class="text-center">
<div class="form-group">
<asp:Panel ID="pError" Visible="false" runat="server">
<div class="alert alert-dismissable alert-danger" id="confirm" runat="server">
<asp:Label ID="lblError" runat="server"> </asp:Label>
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
</div>
</asp:Panel>
</div>
<div role="tabpanel" id="pnl" class="login-tab">
<!-- SCHEDE -->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a id="signin-taba" href="#home" aria-controls="home" role="tab" data-toggle="tab">Accedi</a></li>
<li role="presentation"><a id="signup-taba" href="#profile" aria-controls="profile" role="tab" data-toggle="tab">Registrati</a></li>
<li role="presentation"><a id="forgetpass-taba" href="#forget_password" aria-controls="forget_password" role="tab" data-toggle="tab">Recupero</a></li>
</ul>
<!-- LOGIN -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active text-center" id="home">
<div class="clearfix"></div>
<%-- email --%>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-at"></i></div>
<asp:TextBox ID="txtLoginEmail" CssClass="form-control" placeholder="Email" runat="server"></asp:TextBox>
</div>
<asp:RequiredFieldValidator ID="vLoginEmail" runat="server" Display="dynamic" ControlToValidate="txtLoginEmail" ForeColor="Red" ValidationGroup="validator" ErrorMessage="*Email obbligatoria"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="reLoginEmail" runat="server" ValidationGroup="validator" ControlToValidate="txtLoginEmail" Display="Dynamic" ForeColor="red" ErrorMessage="Inserire l'email nel formato corretto" SetFocusOnError="True" ValidationExpression="\w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-lock"></i></div>
<asp:TextBox type="password" ID="txtLoginPassword" class="form-control" placeholder="Password" runat="server"></asp:TextBox>
</div>
</div>
<asp:Button ID="btnLogin" OnClick="btnLogin_Click" CssClass="btn btn-danger" data-loading-text="Signing In...." ValidationGroup="validator" runat="server" Text="Accedi"></asp:Button>
<input id="resetLogin" class="btn btn-danger" runat="server" type="reset" value="reset" />
<div class="clearfix"></div>
<div class="login-modal-footer">
<div class="row">
<div class="col-xs-8 col-sm-8 col-md-8">
<i class="fa fa-lock"></i>
Recupero
</div>
<div class="col-xs-4 col-sm-4 col-md-4">
<i class="fa fa-check"></i>
Registrati
</div>
</div>
</div>
</div>
<%-- REGISTRAZIONE --%>
<div role="tabpanel" class="tab-pane" id="profile">
<div class="clearfix"></div>
<div class="form-group">
<div class="input-group">
<label class="radio-inline">
<asp:RadioButton ID="rbUtente" GroupName="rbTipologia" Checked="true" runat="server" />Utente</label>
<label class="radio-inline">
<asp:RadioButton ID="rbRistoratore" GroupName="rbTipologia" runat="server" />Ristoratore</label>
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-user"></i></div>
<%-- username --%>
<asp:TextBox class="form-control" ID="txtNome" placeholder="Nome" runat="server"></asp:TextBox>
</div>
<asp:RequiredFieldValidator ID="vtxtNome" runat="server" Display="dynamic" ControlToValidate="txtNome" ForeColor="Red" ValidationGroup="validator2" ErrorMessage="*Nome obbligatorio"></asp:RequiredFieldValidator>
</div>
<%-- cognome --%>
<div class="form-group ">
<div class="input-group ">
<div class="input-group-addon"><i class="fa fa-user"></i></div>
<asp:TextBox class="form-control" ID="txtCognome" placeholder="Cognome" runat="server"></asp:TextBox>
</div>
<asp:RequiredFieldValidator ID="vCognome" runat="server" Display="dynamic" ControlToValidate="txtCognome" ForeColor="Red" ValidationGroup="validator2" ErrorMessage="*Cognome obbligatorio"></asp:RequiredFieldValidator>
</div>
<%-- email --%>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-at"></i></div>
<asp:TextBox class="form-control" ID="txtEmail" placeholder="Email" runat="server"></asp:TextBox>
</div>
<asp:RequiredFieldValidator ID="vEmail" runat="server" Display="dynamic" ControlToValidate="txtEmail" ForeColor="Red" ValidationGroup="validator2" ErrorMessage="*Email obbligatoria"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="reEmail" runat="server" ValidationGroup="validator2" ControlToValidate="txtEmail" Display="Dynamic" ForeColor="red" ErrorMessage="Inserire l'email nel formato corretto" SetFocusOnError="True" ValidationExpression="\w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</div>
<%-- password --%>
<div class="form-group ">
<div class="input-group ">
<div class="input-group-addon"><i class="fa fa-lock"></i></div>
<asp:TextBox type="password" class="form-control" ID="txtPassword" placeholder="Password" runat="server"></asp:TextBox>
</div>
<asp:RequiredFieldValidator ID="vPassword" runat="server" Display="dynamic" ControlToValidate="txtPassword" ForeColor="Red" ValidationGroup="validator2" ErrorMessage="*Password obbligatoria"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="rePassword" runat="server" ValidationGroup="validator2" ControlToValidate="txtPassword" Display="Dynamic" ForeColor="red" ErrorMessage="La password deve contenere: minimo 8 caratteri; almeno 1 maiuscola; almeno 1 minuscola; almeno 1 numero" SetFocusOnError="True" ValidationExpression="^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,15}$"></asp:RegularExpressionValidator>
</div>
<%-- password controllo --%>
<div class="form-group ">
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-lock"></i></div>
<asp:TextBox type="password" class="form-control" ID="txtCPassword" placeholder="Conferma password" runat="server"></asp:TextBox>
</div>
<asp:CompareValidator ID="cvPassword" ValidationGroup="validator2" Display="Dynamic" runat="server" ForeColor="Red" ControlToCompare="txtPassword" ControlToValidate="txtCPassword" ErrorMessage="La password non corrisponde"></asp:CompareValidator>
<asp:Label ID="lblRegistrazione" Visible="false" runat="server" ></asp:Label>
</div>
<asp:Button ID="btnSignin" CssClass="btn btn-danger " data-loading-text="Registrando...." OnClick="btnSignin_Click" ValidationGroup="validator2" runat="server" Text="Registrati"></asp:Button>
<input id="r2" class="btn btn-danger" runat="server" type="reset" value="reset" />
<div class="clearfix"></div>
<div class="login-modal-footer">
<div class="row">
<div class="col-xs-8 col-sm-8 col-md-8">
<i class="fa fa-lock"></i>
Password dimenticata?
</div>
<div class="col-xs-4 col-sm-4 col-md-4">
<i class="fa fa-check"></i>
Registrati
</div>
</div>
</div>
</div>
<div role="tabpanel" class="tab-pane text-center" id="forget_password">
<div class="clearfix"></div>
<%--RECUPERO --%>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-at"></i></div>
<asp:TextBox class="form-control" ID="txtRecEmail" placeholder="Email" runat="server"></asp:TextBox>
</div>
<asp:Label ID="lblRecovery" runat="server" ></asp:Label>
<asp:RequiredFieldValidator ID="vREmail" runat="server" Display="dynamic" ControlToValidate="txtRecEmail" ForeColor="Red" ValidationGroup="validator3" ErrorMessage="*Email obbligatoria"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="reREmail" runat="server" ValidationGroup="validator3" ControlToValidate="txtRecEmail" Display="Dynamic" ForeColor="red" ErrorMessage="Inserire l'email nel formato corretto" SetFocusOnError="True" ValidationExpression="\w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</div>
<asp:Button ID="btnRecovery" OnClick="btnRecovery_Click" CssClass="btn btn-danger reco" data-loading-text="Invio...." ValidationGroup="validator3" runat="server"></asp:Button>
<div class="clearfix"></div>
<div class="login-modal-footer">
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6">
<i class="fa fa-lock"></i>
Registrazione
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<i class="fa fa-check"></i>
Accesso
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
It has 3 tabs: Signin (LOGIN), Signup (Registrazione) and forgot password (RECUPERO).
It is a bit 'difficult to explain but I'll try:
In the 3 cards I have 3 buttons.
If I am in my third card and I press enter key, the computer triggers the onclick event of the button that is located on the first tab.
I tried this jquery code but it doesn't work:
$(document).keypress(function (event) {
var keycode = (event.keyCode ? event.keyCode : event.which);
if (keycode == '13') {
if ($('#home').is(":visible")) {
$("#btnLogin").trigger("click");
}
else if ($('#profile').is(":visible")) {
$("#btnSignin").trigger("click");
}
else {
$('#btnRecovery').click(ShowPopUp);
}
}
}
);
Do you have any solution?
P.S.
If I use the browser's console the javascript code work, but when i try it on my project it doesn't work...
Please help me... this is my exam's project...
Create a local variable(in the jQuery load function) called currentTab
Create a click event for your tabs(<li> tags)
In the click event set the currentTab variable to the clicked <li>
Modify your keypress function to evaluate the currentTab variable and trigger the relevant click event
<script type="text/javascript">
$(function () {
$("#show").click(function () {
jQuery.noConflict();
$("#loginModal").modal('show');
});
var currentTab = "";
$(".nav li").click(function () {
var li = $(this);
var liText = li.text();
currentTab = liText;
alert('You clicked on "' + liText + '" now lets store this value in a variable called currentTab');
});
$(document).keydown(function (event) {
debugger;
var keycode = (event.keyCode ? event.keyCode : event.which);
if (keycode == '13') {
switch (currentTab) {
case "Accedi":
$("#btnLogin").trigger("click");
break;
case "Registrati":
$("#btnSignin").trigger("click");
break;
case "Recupero":
$("#btnRecovery").trigger("click");
break;
}
}
});
});
</script>

Add Form in a Modal

I making an add form in my modal. The modal contains 2 dropdownlists, 4 textboxes (1 hidden) and a button for adding.
I bind my dropdown list for the item category then bind my other dropdown list for the item name. However when I change my Item Category in my dropdown list the dropdown list for my item name is not responding or it not binding. Can anyone help me?
<div id="addModal" class="modal fade">
<div class="modal-dialog modal-md">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Add Item</h4>
</div>
<div class="modal-body">
<div class="form-inline form-group">
<asp:Label ID="Label1" CssClass="control-label col-xs-3" runat="server" Text="Category:"></asp:Label>
<div class="col-xs-offset-3">
<asp:DropDownList ID="drpCategory" runat="server" CssClass="form-control col-xs-5" OnTextChanged="drpCategory_TextChanged" />
</div>
</div>
<div class="form-inline form-group">
<asp:Label ID="Label2" CssClass="control-label col-xs-3" runat="server" Text="Item Name:"></asp:Label>
<div class="col-xs-offset-3">
<asp:TextBox ID="txtitem" runat="server" CssClass="form-control col-xs-5" Visible="false" />
<asp:DropDownList ID="drpItem" runat="server" CssClass="form-control col-xs-5" Visible="true" />
</div>
</div>
<div class="form-inline form-group">
<asp:Label ID="Label3" CssClass="control-label col-xs-3" runat="server" Text="Unit:"></asp:Label>
<div class="col-xs-offset-3">
<asp:TextBox ID="txtUnit" runat="server" CssClass="form-control col-xs-5" Enabled="false" />
</div>
</div>
<div class="form-inline form-group">
<asp:Label ID="Label4" CssClass="control-label col-xs-3" runat="server" Text="Quantity:"></asp:Label>
<div class="col-xs-offset-3">
<asp:TextBox ID="txtQty" runat="server" CssClass="form-control col-xs-3" type="number" min="1" onkeypress="return isNumberKey(event)" />
</div>
</div>
</div>
</div>
<div class="modal-footer">
<asp:Button runat="server" ID="btnADD" CssClass="btn btn-sm" OnClick="btnADD_Click" Text="Add" />
</div>
</div>
</div>
then this is the code behind:
public void drpCategory_TextChanged(object sender, EventArgs e)
{
if (drpCategory.Text == "Others")
{
drpItem.Visible = false;
txtitem.Visible = true;
}
else
{
byCateg();
DataBind();
drpItem.Visible = true;
txtitem.Visible = false;
}
}
Is there a problem in my code?

Categories

Resources