The div contain html controls like dropdown , textboxes etc.Dropdown data is binding using c# code . when a dropdown repeats the binded data must be repeat . how can i implement it using jquery ?
You can add repeated div using bellow code: Working Fiddle
<input type="button" value="Add More(+)" id="btnAddMore" /> <br/>
<div id="divMain"></div>
<div id="divToCopy" style="display:none;">
<div>
<label>Text: </label>
<input type="text"><br/>
<label>Dropdown: </label>
<select>
<option>value1</option>
<option>value2</option>
</select>
</div>
</div>
Jquery Code:
$("#btnAddMore").click(function(){
var divCopy=$("#divToCopy").html();
$("#divMain").append(divCopy);
});
Related
Using ASP .Net Core (Version 2.2, NON-MVC)
I have a database field (Car) which contains text, in HTML format.
I am using an ASP .Net "Input" Helper Tag to display the data (read only) on a webpage.
<input asp-for="Car.Description" asp-format="" disabled class="form-control" />
I would like to display the data as Html.Raw, but am unsure how to do so.
I originally thought I could do something like this (use Html.Raw), but this throws an exception:
<input asp-for=#Html.Raw(Car.Description) asp-format="" disabled class="form-control" />
I then thought the "asp-format" field might have some usable options, but I don't see any.
<div class="form-group row">
<div class="col-2">
<label asp-for="Car.Description"></label>
</div>
<div class="col-10">
<input asp-for="Car.Description" asp-format="" disabled class="form-control" />
</div>
</div>
End result is that I would like to have the display "raw" HTML on the screen.
Thanks
If you want to display the field as read only, you may not even need the "input" helper tag. Just displaying the data in the div should work.
Remove the input helper and just display the text in the div as follows:
<div class="form-group row">
<div class="col-2">
<label asp-for="Car.Description"></label>
</div>
<div class="col-10">
#Html.Raw(Car.Description)
</div>
</div>
Please, I'm stuck trying to send my radio button user choice to the aspx.cs file and sent it to SQL, so here's the code:
<div class="form-group">
<label class="control-label col-sm-3">Status</label>
<div class="col-sm-6">
<div class="row" id="row" runat="server">
<div class="col-sm-4">
<label class="radio-inline">
<input type="radio" id="nsent" value="nsent" name="status" runat="server" checked="true">Not Sent
</label>
</div>
<div class="col-sm-4">
<label class="radio-inline">
<input type="radio" id="sent" value="sent" name="status" runat="server">Sent
</label>
</div>
</div>
</div>
So after I click Submit, there's a code to send it to SQL, but I don't have any idea how I would send the value selected in the HTML.
Selected Item or Selected Value won't work, even InnerText.
for a radio button, and in WEBFORMS, you would look at both control's CHECK state
if (sent.Checked) == true {...}
if (nsent.Checked == true) {...}
Alternatively you could review the FORMS collection that was submitted with the Page.Request (if this is a POSTBACK).
if (page.request.forms["status"] == "sent") {
...
} elseif (page.request.forms["status"] =="nsent" {
...
}
A third option, which seems to be outside the scope of your question is to read the radio buttons on the client side, and submit the value to the server via some AJAX style submission.
You should use <asp:Checkbox> (ASP.NET WebForms) or #Html.CheckBoxFor() (ASP.NET MVC).
I am using ascx page. which I am injecting in UMBRACO.
following is my .ascx Code.
<form id="main-contact-form" name="contact-form" method="post" action="#">
<div class="form-group">
<input type="text" runat="server" name="name" id="txtName" class="form-control" placeholder="Name" required />
</div>
<button type="submit" class="btn-primary">Send Message</button>
</form>
I have try to get value of text box (txtName) from back end but I am not abe to access it.
I have tried following method to do so..(Where strtxtName is a string variable)
1) strtxtName = txtName.Value
2) strtxtName = Request.QueryString("txtName")
3) Request.Form.AllKeys -> return Nothing.
But not able to get value of text Box ,
I don't think Umbraco is making any issue.?
Here I made a simple webpage to post pictures, text, etc. I also made a simple ajax file to send the text, picture, etc to the database, and retrieve that information to be displayed in the same webpage. Here is the main webpage:
<div class="here" id="here">
#foreach (var photo in db.Query(photos, galleryInfo)){
<div class="com_1 com_3">
<div class="com_4">
<div class="com_44">
<img alt="miniatura" style="margin-top: 0" src="#Href("~/Photo/Thumbnail2", photo.UserId, new { size="small" })" class="thumbnail-border thumb22" />
<div class="n-s">
<b>#photo.Nombre #photo.Apellido</b>
</div>
</div>
<div class="com_5">
#photo.Comment
</div>
</div>
<div class="comcom">
<div class="comcom1">
<form onsubmit="return fofon(this)" id="gog">
<input type="text" style="display: none" name="GroupId" value="#galleryInfo" />
<textarea class="texta"name="comment" placeholder="Write a comment..."></textarea>
<input type="submit" class="g_sub"/>
</form>
</div>
</div>
</div>
}
In case it gets confuse, this shows every post with a "comment section" below each one (we can call them "Commne2"). The ajax will get the text, picture etc, send it to the database, and post it to another file, which will be displayed here... in the #foreach{}.
Obviously, the posts do not "excist", so any javascript that affects that post, will not work, because that element does not exciste in this case.
So my problem is, how can I create an ajax file (javascript file) that affects the Comment2 so that I can comment a post?
I use DNN and C#. I've got a form with a lot of input and select HTML tag. At the end of form there is a . When I click on it, the page is reload but when I try catch data of form (with Request.Form['formName'] or Request['form']) I've got only empty field (and if I check the value of IsPostback, it's always false). But in the form tag there is value.
FILE View.ascx
<div class="row">
<div class="col-sm-2"> </div>
<div class="col-sm-4">
<label for="formCodiceCanile">Codice Canile</label>
</div>
<div class="col-sm-4">
<input type="text" name="formCodiceCanile" ID="formCodiceCanile" value="<%=InfoScheda.CodiceCanile %>" />
</div>
<div class="col-sm-2"> </div>
</div>
OTHER FIELD (such as input text, select and radio button)
<input type="submit" name="formRegistraScheda" id="formRegistraScheda" value="Registra scheda" />
I know that I can use (and if I use it, there isn't problem because catch the value in the asp:Textbox it's a joke) but in this case I can't use them.
How can I resolve this problem?
PROBLEM SOLVED: the button doesn't do the POST because I use a field's form in the URL to observe the page status. Now I remove this control and I use the IsPostback native variable of C# and the form work!