Bootstrap modal's button ASP.NET C# - 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>

Related

Unable to trigger onchange event from select tag in ASP.Net

I want to change the textboxes that should be displayed based on accountType the user selects. However, the onchange event attached to select is not getting triggered. Any heads up?
This is the select tag.
<div class="col-md-12 form-group" style="color:black">
<select name="accountTypes" id="accountTypes" runat="server" onchange="javascript:document.forms[0].submit();" onserverchange="accountType_Changed">
<option value="customer">Customer</option>
<option value="pharmacy">Pharmacy</option>
<option value="doctor">Doctor</option>
</select>
</div>
The accountType_Changed function is:
void accountType_Changed(Object sender, EventArgs e)
{
cnic.Text = accountTypes.SelectedItem.Value;//or accountTypes.SelectedItem.Text
}
Edit:
Based on the solution proposed by #mahesh_b, following edits were made that fixed the problem:
protected void Page_Load(object sender, EventArgs e)
{
this.accountTypes.Attributes.Add("onchange", Page.ClientScript.GetPostBackEventReference(this.accountTypes, this.accountTypes.ID));
}
protected void accountType_Changed(object sender, EventArgs e)
{
cnic.Text = "Working!!!"; //accountTypes.SelectedItem.Value;//or accountTypes.SelectedItem.Text
}
Edit 2: Layout Rendering Issue after adding partial refresh
Login.aspx:
<asp:ScriptManager EnablePartialRendering="true" ID="scriptManager" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<section class="login_part section_padding ">
<div class="container">
<div class="row align-items-center">
<div class="col-lg-6 col-md-6">
<div class="login_part_text text-center">
<div class="login_part_text_iner">
<h2>New to PHS?</h2>
<div class="row">
<div class="column col-md-12 form-group p_star">
<div class="col-md-12 form-group p_star">
<asp:TextBox ID="firstname" placeholder="First Name" class="form-control" runat="server">
</asp:TextBox>
</div>
</div>
<div class="column col-md-12 form-group p_star">
<div class="col-md-12 form-group p_star">
<asp:TextBox ID="lastname" placeholder="Last Name" class="form-control" runat="server">
</asp:TextBox>
</div>
</div>
</div>
<div class="col-md-12 form-group p_star">
<asp:TextBox ID="cnic" placeholder="CNIC" class="form-control" runat="server">
</asp:TextBox>
</div>
<div class="col-md-12 form-group p_star">
<asp:TextBox ID="email" placeholder="Email" class="form-control" runat="server">
</asp:TextBox>
</div>
<div class="col-md-12 form-group p_star">
<asp:TextBox ID="pass" placeholder="Password" class="form-control" runat="server">
</asp:TextBox>
</div>
<div class="col-md-12 form-group" style="color:black">
<select name="accountTypes" id="accountTypes" runat="server" onchange="javascript:document.forms[0].submit();" onserverchange="accountType_Changed">
<option value="customer">Customer</option>
<option value="pharmacy">Pharmacy</option>
<option value="doctor">Doctor</option>
</select>
</div>
<br /><br />
<div class="col-md-12 form-group p_star">
<asp:TextBox ID="taxNo" placeholder="Tax No" class="form-control" runat="server">
</asp:TextBox>
</div>
<div class="col-md-12 form-group p_star">
<asp:TextBox ID="pName" placeholder="Pharmacy Name" class="form-control" runat="server">
</asp:TextBox>
</div>
<div class="col-md-12 form-group p_star">
<asp:TextBox ID="pAddress" placeholder="Pharmacy Address" class="form-control" runat="server">
</asp:TextBox>
</div>
<div class="col-md-12 form-group p_star">
<asp:TextBox ID="cAddress" placeholder="Address" class="form-control" runat="server">
</asp:TextBox>
</div>
<div class="col-md-12 form-group p_star">
<asp:TextBox ID="docID" placeholder="Doctor Id" class="form-control" runat="server">
</asp:TextBox>
</div>
<div class="col-md-12 form-group p_star">
<asp:TextBox ID="experience" placeholder="Experience (Years)" class="form-control" runat="server">
</asp:TextBox>
</div>
<div class="col-md-12 form-group p_star">
<asp:TextBox ID="expertise" placeholder="Expertise (Specialization)" class="form-control" runat="server">
</asp:TextBox>
</div>
<br />
<p>Create an account today and avail the best deals on medics.</p>
<asp:Button ID="registerButton" class="btn_3" runat="server" width="50%" Text="Create Account" OnClick="createAccount_Clicked"/>
</div>
</div>
</div>
<div class="col-lg-6 col-md-6">
<div class="login_part_form">
<div class="login_part_form_iner">
<h3>Welcome Back ! <br>
Please Sign in now</h3>
<form class="row contact_form" action="#" method="post" novalidate="novalidate">
<div class="col-md-12 form-group p_star">
<input type="text" class="form-control" id="name" name="name" value=""
placeholder="Username">
</div>
<div class="col-md-12 form-group p_star">
<input type="password" class="form-control" id="password" name="password" value=""
placeholder="Password">
</div>
<div class="col-md-12 form-group">
<button type="submit" value="submit" class="btn_3">
log in
</button>
<a class="lost_pass" href="#">forget password?</a>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</section>
</ContentTemplate>
</asp:UpdatePanel>
These images show the original layout of select and what gets loaded after I change the value:
Original:
This is what gets loaded after changing the value in accountType:
How can I get to keep my original layout?
You need to use ASP.NET Dropdownlist with using AutoPostBack=true to trigger OnChange event:
<div class="col-md-12 form-group" style="color:black">
<asp:DropDownList id="accountTypes" AutoPostBack="True" OnSelectedIndexChanged="accountType_Changed" runat="server">
<asp:ListItem Value="account_type">Account Type</asp:ListItem>
<asp:ListItem Value="customer"> Customer </asp:ListItem>
<asp:ListItem Value="pharmacy"> Pharmacy </asp:ListItem>
<asp:ListItem Value="doctor"> Doctor </asp:ListItem>
</asp:DropDownList>
</div>
And server side accountType_Changed would be like this:
void accountType_Changed(Object sender, EventArgs e)
{
username.Text = accountTypes.SelectedItem.Value;//or accountTypes.SelectedItem.Text
}
For HTML controls use the server events, in your case OnServerChange event. In order the serverchange event to fire you have to explicitly submit the form or do a postback on onchange event. You can do this with below two options -
Submit the form on onchange event from client side:
<select name="accountTypes" id="accountTypes" runat="server"
onchange="javascript:document.forms[0].submit();" onserverchange="accountType_Changed">
Use the GetPostBackEventReference method from server side:
protected void Page_Load(object sender, EventArgs e)
{
this.accountTypes.Attributes.Add("onchange", Page.ClientScript.GetPostBackEventReference(this.accountTypes, this.accountTypes.ID));
}
You may have to also change the method signature to-
protected void accountType_Changed(object sender, EventArgs e)
{
}
Refer these threads to understand more on the same -
How to make HtmlSelect Control with OnChange event to trigger C# code behind function
OnServerChange event not firing
If your requirement can fit with changing to ASP.NET Drop down list then you can follow which Selim mentioned in another answer.

How to add RequiredFieldValidator on a Ajax Editor 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

postback error in multiview

I used multi view in my web site. I wanna insert news in this website in step 1 I insert short description and some other data when I want to go to step 2 I received this error:
Invalid postback or callback argument. Event validation is enabled
using in configuration or <%#
Page EnableEventValidation="true" %> in a page. For security
purposes, this feature verifies that arguments to postback or callback
events originate from the server control that originally rendered
them. If the data is valid and expected, use the
ClientScriptManager.RegisterForEventValidation method in order to
register the postback or callback data for validation.
code
<%# Page Title="" Language="C#" MasterPageFile="~/AdminMaster.master" AutoEventWireup="true" CodeFile="AdminNews.aspx.cs" ValidateRequest="false" Inherits="AdminNews" %>
</asp:View>
<asp:View ID="Vnew" runat="server">
<div class="col-md-12 col-xs-12 col-sm-12">
<div class="col-md-1 col-xs-12 col-sm-1"></div>
<div class="col-md-10 col-xs-12 col-sm-10">
<section class="panel text-center">
<header class=" label label-info icon-plus-sign text-center">
درج خبر جدید
</header>
<div class="panel-body">
<div class="btn-group btn-group-justified">
<div class="col-md-12 col-xs-12 col-sm-12">
<form role="form">
<div class="form-group">
<label for="exampleInputEmail1" class="pull-right">نام:</label>
<asp:TextBox ID="txtNameNew" runat="server" type="text" class="form-control pull-right"></asp:TextBox>
</div>
<br />
<div class="form-group">
<label for="exampleInputPassword1" class="pull-right">تاریخ:</label>
<asp:TextBox ID="txtDateNew" runat="server" type="text" class="form-control pull-right" ></asp:TextBox>
</div>
<br />
<div class="form-group">
<label for="exampleInputPassword1" class="pull-right">دسته خبر: </label>
<asp:DropDownList ID="ddlCategoryNew" runat="server" CssClass=" form-control">
</asp:DropDownList>
</div>
<br />
<div class="form-group">
<label for="exampleInputPassword1" class="">توضیحات کوتاه </label>
<br />
<br />
<br />
<textarea id="txtShortDEsNew" cols="20" rows="10" runat="server" class="form-control pull-right"></textarea>
</div>
<div class=" form-group">
<label for="exampleInputFile" class="pull-Right"> یک تصویرانتخاب کنید.</label>
<asp:FileUpload ID="fuNew" CssClass="" runat="server" />
</div>
</form>
<asp:Label ID="lblWarning" runat="server" Text="هیچ تصویری انتخاب نکرده اید." CssClass="fixWarning2"></asp:Label>
<div class="col-md-2 col-xs-12 col-sm-2 "><div class="label-default"> </div></div>
<div class="pull-right col-md-10 col-xs-12 col-sm-10">
</div>
</div>
</div>
</div>
<div class="col-md-12 col-xs-12 col-sm-12 PaddingZiro">
<div class="col-md-1 col-xs-12 col-sm-1 pull-right"></div>
<div class="col-md-10 col-xs-12 col-sm-10 pull-right">
<div class="col-md-12 col-xs-12 col-sm-12 myheader">
<div class="col-md-1 col-xs-12 col-sm-1 pull-right"></div>
<div class="col-md-10 col-xs-12 col-sm-10 pull-right">
<div class="col-md-12 col-xs-12 col-sm-12 fixWarning2">
</div>
<div class="col-md-12 col-xs-12 col-sm-12 fixWarning2">
</div>
</div>
<div class="col-md-12 col-xs-12 col-sm-12 MarginBotom15">
<div class="pull-right col-md-3 col-xs-12 col-sm-3 NewSocialnetTTl">تصویر: </div>
</div>
<div class="col-md-12 col-xs-12 col-sm-12 MarginBotom15">
<div class="pull-right col-md-3 col-xs-12 col-sm-3 NewSocialnetTTl"></div>
<div class="pull-right col-md-9 col-xs-12 col-sm-9">
<asp:LinkButton ID="returnbtn" runat="server" CssClass="btn btn-warning pull-left" OnClick="lbtnReturn_Click">بازگشت</asp:LinkButton>
<asp:LinkButton ID="SocialRegist" runat="server" CssClass="btn btn-success pull-left MarginLeft20" OnClick="lbtnInsertStep1_Click">مرحله بعد</asp:LinkButton>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
</div>
</asp:View>
<asp:View ID="vnewStep2" runat="server">
<div class="col-md-12 col-xs-12 col-sm-12 PaddingZiro">
<div class="col-md-1 col-xs-12 col-sm-1 pull-right"></div>
<div class="col-md-10 col-xs-12 col-sm-10 pull-right">
<div class="col-md-12 col-xs-12 col-sm-12 myheader">
توضیحات اصلی
<asp:Label ID="lblNewsMaxid" runat="server" Text="" Visible="false"></asp:Label>
</div>
</div>
</div>
<div class="col-md-12 col-xs-12 col-sm-12 PaddingZiro">
<div class="col-md-1 col-xs-12 col-sm-1 pull-right"></div>
<div class="col-md-10 col-xs-12 col-sm-10 pull-right">
<div class="col-md-12 col-xs-12 col-sm-12 myheader">
<div class="col-md-12 col-xs-12 col-sm-12 text-center fixWarning2 MarginBotom15">برای آپلود فایل از این قسمت می توانید استفاده کنید</div>
<div class="col-md-12 col-xs-12 col-sm-12 ">
<div class="col-md-3 col-xs-12 col-sm-3 pull-right"></div>
<div class="col-md-6 col-xs-12 col-sm-6 pull-right text-center">
<asp:Label ID="Label1" runat="server" Text="Label" CssClass="pull-right">انتخاب فایل</asp:Label>
<asp:LinkButton ID="btnAboutUsInsertFiles" runat="server" CssClass="btn btn-success pull-left" OnClick="btnInsertFiles_Click">ارسال</asp:LinkButton>
<asp:FileUpload ID="fuFilesTable" runat="server" CssClass="pull-left" />
</div>
<div class="col-md-3 col-xs-12 col-sm-3 pull-right"></div>
</div>
<div class="col-md-12 col-xs-12 col-sm-12 ">
<asp:Label ID="lblSiteName" runat="server" Text=""></asp:Label>
<asp:GridView ID="GVFilesTable" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4" DataKeyNames="id" Width="100%" OnRowCommand="GVProductsFiles_RowCommand">
<Columns>
<asp:BoundField DataField="id" HeaderText="کد" HeaderStyle-CssClass="ProductBoxHeaderStyle">
<HeaderStyle CssClass="ProductBoxHeaderStyle" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" BorderColor="#047269" BorderWidth="2px" />
</asp:BoundField>
<asp:BoundField DataField="Pic" HeaderText="عکس" HeaderStyle-CssClass="ProductBoxHeaderStyle">
<HeaderStyle CssClass="ProductBoxHeaderStyle" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" BorderColor="#047269" CssClass="GVItemStyle" />
</asp:BoundField>
<asp:TemplateField HeaderText="حذف" HeaderStyle-CssClass="ProductBoxHeaderStyle">
<ItemTemplate>
<asp:LinkButton ID="btnProductDelletFile" runat="server" CssClass="btn btn-warning" Text="حذف" CommandArgument='<%#Eval("id") %>' CommandName="DeleteFile">حذف</asp:LinkButton>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" BorderColor="#047269" CssClass="GVItemStyle" />
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<textarea id="txtLongDEsNew" cols="20" rows="25" runat="server"></textarea>
<asp:Label ID="lblRegistWarning" runat="server" Text="متن شما با موفقیت ذخیره شد" CssClass="fixWarning2"></asp:Label>
<div class="col-md-12 col-xs-12 col-sm-12 margintop10px">
<div class="col-md-3 col-xs-12 col-sm-3 pull-right"></div>
<div class="col-md-6 col-xs-12 col-sm-6 pull-right text-center">
<asp:LinkButton ID="btnAboutUsSave" runat="server" CssClass="btn btn-success pull-right" OnClick="lbtnInserStep2_Click">ذخیره</asp:LinkButton>
<asp:LinkButton ID="btnAboutUsReturn" runat="server" CssClass="pull-left btn btn-info" OnClick="lbtnReturn_Click">بازگشت</asp:LinkButton>
</div>
<div class="col-md-3 col-xs-12 col-sm-3 pull-right"></div>
</div>
</div>
</div>
</div>
</asp:View>
<asp:View ID="vEdith" runat="server">
<div class="col-md-12 col-xs-12 col-sm-12 PaddingZiro">
<div class="col-md-1 col-xs-12 col-sm-1 pull-right"></div>
<div class="col-md-10 col-xs-12 col-sm-10 pull-right">
<div class="col-md-12 col-xs-12 col-sm-12 myheader">
ویرایش
</div>
</div>
</div>
<div class="col-md-12 col-xs-12 col-sm-12 PaddingZiro">
<div class="col-md-1 col-xs-12 col-sm-1 pull-right"></div>
<div class="col-md-10 col-xs-12 col-sm-10 pull-right">
<div class="col-md-12 col-xs-12 col-sm-12 myheader">
<div class="col-md-12 col-xs-12 col-sm-12 text-center MarginBotom15">
<asp:ImageButton ID="img_edith" runat="server" />
</div>
<div class="col-md-12 col-xs-12 col-sm-12 MarginBotom15">
<div class="pull-right col-md-3 col-xs-12 col-sm-3 NewSocialnetTTl">ویرایش تصویر: </div>
<asp:FileUpload ID="fUEdith" runat="server" />
</div>
<div class="col-md-12 col-xs-12 col-sm-12 MarginBotom15">
<div class="pull-right col-md-2 col-xs-12 col-sm-2 NewSocialnetTTl">نام: </div>
<div class="pull-right col-md-10 col-xs-12 col-sm-10">
<asp:TextBox ID="txtNameEdith" runat="server" type="text" class="form-control pull-right"></asp:TextBox>
</div>
</div>
<div class="col-md-12 col-xs-12 col-sm-12 MarginBotom15">
<div class="pull-right col-md-2 col-xs-12 col-sm-2 NewSocialnetTTl">تاریخ </div>
<div class="pull-right col-md-10 col-xs-12 col-sm-10">
<asp:TextBox ID="txtDateEdith" runat="server" type="text" class="form-control pull-right"></asp:TextBox>
</div>
</div>
<div class="col-md-12 col-xs-12 col-sm-12 MarginBotom15">
<div class="pull-right col-md-2 col-xs-12 col-sm-2 NewSocialnetTTl">دسته بندی: </div>
<div class="pull-right col-md-10 col-xs-12 col-sm-10">
<asp:DropDownList ID="DdlCategoryEdith" runat="server" CssClass="form-control Myform-control">
</asp:DropDownList>
</div>
</div>
<div class="col-md-12 col-xs-12 col-sm-12 MarginBotom15">
<div class="pull-right col-md-2 col-xs-12 col-sm-2 NewSocialnetTTl">توضیحات کوتاه: </div>
<div class="pull-right col-md-10 col-xs-12 col-sm-10">
<textarea id="txtShortDescribEdith" cols="20" rows="10" runat="server" class="form-control pull-right"></textarea>
</div>
</div>
<div class="col-md-12 col-xs-12 col-sm-12 margintop10">
<div class="col-md-2 col-xs-12 col-sm-2 pull-right"></div>
<div class="col-md-8 col-xs-12 col-sm-8 pull-right text-center">
<asp:Label ID="Label3" runat="server" Text="Label" CssClass="pull-right">انتخاب فایل</asp:Label>
<asp:LinkButton ID="LinkButton8" runat="server" CssClass="btn btn-success pull-left" OnClick="lbtnSendFileInEdith_Click">ارسال</asp:LinkButton>
<asp:FileUpload ID="FuProductEdithINNEr" runat="server" CssClass="pull-left" />
<div class="col-md-12 col-xs-12 col-sm-12 margintop10">
<asp:Label ID="Label2" runat="server" Text=""></asp:Label>
<asp:GridView ID="GVproductFileinedith" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px"
CellPadding="4" DataKeyNames="id" Width="100%" OnRowCommand="GVproductFileinedith_RowCommand">
<Columns>
<asp:BoundField DataField="id" HeaderText="کد" HeaderStyle-CssClass="ProductBoxHeaderStyle">
<HeaderStyle CssClass="ProductBoxHeaderStyle" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" BorderColor="#047269" BorderWidth="2px" />
</asp:BoundField>
<asp:BoundField DataField="ApicUrl" HeaderText="آدرس" HeaderStyle-CssClass="ProductBoxHeaderStyle">
<HeaderStyle CssClass="ProductBoxHeaderStyle" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" BorderColor="#047269" CssClass="GVItemStyle" />
</asp:BoundField>
<asp:TemplateField HeaderText="حذف" HeaderStyle-CssClass="ProductBoxHeaderStyle">
<ItemTemplate>
<asp:LinkButton ID="btnProductDelletFile" runat="server" CssClass="btn btn-warning" Text="حذف" CommandArgument='<%#Eval("id") %>' CommandName="DeleteFile">حذف</asp:LinkButton>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" BorderColor="#047269" CssClass="GVItemStyle" />
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</div>
</div>
<div class="col-md-12 col-xs-12 col-sm-12 margintop10">
<textarea id="txtLongDescribeEdit" cols="20" rows="20" runat="server"></textarea>
</div>
<div class="col-md-12 col-xs-12 col-sm-12 margintop10px">
<div class="col-md-3 col-xs-12 col-sm-3 pull-right"></div>
<div class="col-md-6 col-xs-12 col-sm-6 pull-right text-center">
<asp:LinkButton ID="lbtnEdithNews" runat="server" CssClass="btn btn-success pull-right" OnClick="lbtnEdithNews_Click">ذخیره</asp:LinkButton>
<asp:LinkButton ID="lbtnReturn" runat="server" CssClass="pull-left btn btn-info" OnClick="lbtnReturn_Click">بازگشت</asp:LinkButton>
</div>
<div class="col-md-3 col-xs-12 col-sm-3 pull-right"></div>
</div>
</div>
</div>
</div>
</asp:View>
<asp:View ID="vDelet" runat="server">
<div class="col-md-12 col-xs-12 col-sm-12 PaddingZiro">
<div class="col-md-1 col-xs-12 col-sm-1 pull-right"></div>
<div class="col-md-10 col-xs-12 col-sm-10 pull-right">
<div class="col-md-12 col-xs-12 col-sm-12 myheader">
حذف
</div>
</div>
</div>
<div class="col-md-12 col-xs-12 col-sm-12 PaddingZiro">
<div class="col-md-1 col-xs-12 col-sm-1 pull-right"></div>
<div class="col-md-10 col-xs-12 col-sm-10 pull-right">
<div class="col-md-12 col-xs-12 col-sm-12 myheader">
آیا با حذف موافقید؟
<div class="col-md-12 col-xs-12 col-sm-12 MarginBotom15">
<div class="pull-right col-md-4 col-xs-12 col-sm-4 NewSocialnetTTl"></div>
<div class="pull-right col-md-4 col-xs-12 col-sm-4 text-center">
<asp:LinkButton ID="LinkButton2" runat="server" CssClass="btn btn-warning pull-left" OnClick="lbtnReturn_Click">بازگشت</asp:LinkButton>
<asp:LinkButton ID="LinkButton3" runat="server" CssClass="btn btn-success pull-right MarginLeft20" OnClick="lbtnDelet_Click">حذف</asp:LinkButton>
</div>
<div class="pull-right col-md-4 col-xs-12 col-sm-4 NewSocialnetTTl"></div>
</div>
</div>
</div>
</div>
</asp:View>
<asp:View ID="vComment" runat="server">
<div class="col-md-12 col-xs-12 col-sm-12 PaddingZiro">
<div class="col-md-1 col-xs-12 col-sm-1 pull-right"></div>
<div class="col-md-10 col-xs-12 col-sm-10 pull-right">
<div class="col-md-12 col-xs-12 col-sm-12 myheader text-center">
نظرات کاربران
<br />
<br />
<asp:Label ID="lblCommentWarning" runat="server" Text="در خواست شما با موفقیت انجام شد" CssClass="fixWarning" Visible="false"></asp:Label>
</div>
</div>
</div>
<div class="col-md-12 col-xs-12 col-sm-12 PaddingZiro">
<div class="col-md-1 col-xs-12 col-sm-1 pull-right"></div>
<div class="col-md-10 col-xs-12 col-sm-10 pull-right">
<div class="col-md-12 col-xs-12 col-sm-12">
<%-- every comment start from here--%>
<asp:DataList ID="dlMessage" runat="server" OnItemCommand="dlMessage_ItemCommand">
<ItemTemplate>
<div class="col-md-12 col-xs-12 col-sm-12 MarginBotom15 commentStyle">
<div class="col-md-4 col-xs-4 col-sm-4 pull-right">
<asp:Label ID="lblCommentName" runat="server" Text='<%#Eval("name") %>'></asp:Label>
</div>
<div class="col-md-4 col-xs-4 col-sm-4 pull-right text-center">
<div class="col-md-6 col-xs-12 col-sm-6 pull-right text-center">
<i class="fa fa-thumbs-o-up" aria-hidden="true"> </i>
<asp:Label ID="lblCommentLike" runat="server" Text='<%#Eval("cmlike") %>'></asp:Label>
</div>
<div class="col-md-6 col-xs-12 col-sm-6 pull-right text-center">
<i class="fa fa-thumbs-o-down" aria-hidden="true"> </i>
<asp:Label ID="lblCommentDisLike" runat="server" Text='<%#Eval("dislike") %>'></asp:Label>
</div>
</div>
<div class="col-md-4 col-xs-4 col-sm-4 pull-right">
<asp:LinkButton ID="lbtnCommentDelet" runat="server" CssClass=" btn btn-danger " data-toggle="tooltip" title="حذف" CommandName="delete" CommandArgument='<%#Eval("id")%>'>
<i class=" icon-trash" aria-hidden="true"></i>
</asp:LinkButton>
<asp:LinkButton ID="lbtnMCommentBlock" runat="server" CssClass="btn btn default pull-left hlBlock" data-toggle="tooltip" title="غیر فعال کردن" CommandName="block" CommandArgument='<%#Eval("id")%>'>
<i class=" icon-ban-circle " aria-hidden="true"></i>
</asp:LinkButton>
<span class="pull-left spacerStyle">/</span>
<asp:LinkButton ID="lbtnCommentActive" runat="server" CssClass="btn btn default pull-left hlActive" data-toggle="tooltip" title="فعال کردن" CommandName="active" CommandArgument='<%#Eval("id")%>'>
<i class=" icon-check " aria-hidden="true"></i>
</asp:LinkButton>
</div>
<div class="col-md-12 col-xs-12 col-sm-12 MarginBotom15 text-justify">
<asp:Label ID="lblCommentBody" runat="server" Text='<%#Eval("commentBdy") %>'></asp:Label>
</div>
<div class="col-md-12 col-xs-12 col-sm-12 MarginBotom15 text-justify">
<div class="col-md-2 col-xs-12 col-sm-2 pull-right text-center">
<asp:Label ID="lblCommentDate" runat="server" Text='<%#Eval("commentdate") %>'></asp:Label>
</div>
<div class="col-md-2 col-xs-12 col-sm-2 pull-right text-center">
<asp:Label ID="lblCommentTime" runat="server" Text='<%#Eval("time") %>'></asp:Label>
</div>
<div class="col-md-4 col-xs-12 col-sm-4 pull-right text-center">
<asp:Label ID="lblCommentip" runat="server" Text='<%#Eval("ip") %>'></asp:Label>
</div>
<div class="col-md-4 col-xs-12 col-sm-4 pull-right text-center">
<asp:Label ID="lblCommentEmail" runat="server" Text='<%#Eval("email") %>'></asp:Label>
</div>
</div>
</div>
</ItemTemplate>
</asp:DataList>
</div>
</div>
</div>
</asp:View>
</asp:MultiView>
</section>
</section>
</asp:Content>
whats wrong ?

Accessing bootstrap Modal Controls from CodeBehind c# web forms

I am using bootstrap data-id to populate the controls in modal bootstrap.
After this action, once user makes changes to the input values, on button click I want to access those values in c# Code behind and submit those values to database.
http://www.aspsnippets.com/demos/267/
The link show to use hidden field,
Here is my code so far
<asp:HiddenField ID="hdnField" runat="server" Value="" />
<a href="#" data-target="#my_modal" data-toggle="modal" class="myModalDialog"
data-id="First Name" data-name="My Name">Open Modal</a>
<div class="modal fade hmodal-info" id="my_modal" tabindex="4000" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="color-line">
</div>
<div class="modal-header text-center">
<h4 class="modal-title">
Edit Details</h4>
<small class="font-bold"> Name Goes here.</small>
</div>
<div class="modal-body">
<p>
some content</p>
<input type="text" name="bookId" id="bookId" value="" />
<input type="text" name="bookName" id="bookName" value="" />
<asp:TextBox ID="txtVendorId" runat="server"></asp:TextBox>
</div>
<div class="modal-footer">
<asp:Button ID="btnCallServer" runat="server" Text="Submit" />
<asp:Label ID="Label1" runat="server" Text="Click here to submit" class="btn btn-success" ></asp:Label>
<asp:HiddenField ID="HiddenField1" runat="server" Value="" />
</div>
</div>
</div>
</div>
$(document).ready(function () {
$(document).on("click", ".myModalDialog", function () {
var myBookId = $(this).data('id');
alert($(this).data('name'));
$(".modal-body #bookId").val(myBookId);
var myBookName = $(this).data('name');
$(".modal-body #bookName").val(myBookName);
$('[id$=txtVendorId]').val(myBookName);
});//href click
$('#<% =Label1.ClientID %>').click(function (e) {
var txt = "";
txt = $('#<% =txtVendorId.ClientID %>').val();
$("#<%=btnSubmit.ClientID%>").click();
});
});//documnet ready
<div class="modal fade hmodal-info" id="my_modal" tabindex="4000" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="color-line">
</div>
<div class="modal-header text-center">
<h4 class="modal-title">
Edit Details</h4>
<small class="font-bold"> Name Goes here.</small>
</div>
<div class="modal-body">
<p>
some content</p>
<input type="text" name="bookId" id="bookId" value="" />
<input type="text" name="bookName" id="bookName" value="" />
<asp:TextBox ID="txtVendorId" runat="server"></asp:TextBox>
</div>
<div class="modal-footer">
<asp:Button ID="btnCallServer" runat="server" Text="Submit" />
<asp:Label ID="Label1" runat="server" Text="Click here to submit" class="btn btn-success" ></asp:Label>
<asp:HiddenField ID="HiddenField1" runat="server" Value="" />
</div>
</div>
</div>
</div>

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