Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am using hidden type form value in HTML. how we connect this with javascript and jquery.
I tried this:
HTML :
<label>Company Name:</label><br />
<input type="text" name="21602-0" id="21602-0" size="30" value="<%= FormValues["21602-0"] % />
JS:
vars[1] != null ? $('#21620-' + index.toString()).val(vars[1]) : $('#21620-' + index.toString()).val('');
Hidden fields are those fields as their name suggest which are not visible on UI (but available in source html), you can maintain state of some element using these field.
Now to access these field by name using jQuery try:
var text = $('[name="ElementNameHere"]').val();
and to set field value:
$('[name="ElementNameHere"]').val('new Text');
and using JavaScript:
var text = document.getElementsByName('ElementNameHere').value;
//or set new text
document.getElementsByName('ElementNameHere').value= 'new text';
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I have a text in SQL like: "I want to eat. I'm hungry."
I use ASP.NET MVC to get data from database:
#Model.content
#Model.content is "I want to eat. I'm hungry."
I want to format text to display, for example, it might come down the line:
I want to eat.
I'm hungry.
Since, you don't prefer saving "\n" in the database, you can just split the entire into an array and loop through each item to display it with breaks. use Split
Something like:
#foreach (var item in Model.content.Split(".")) { #item <br /> }
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I've got a large .net form with hundreds of input fields, sometimes users navigate off the form page without saving, what's the best way to check if a field value has changed when they try to navigate away? some c# function or javascript?
Don't take the control out of the users hand :-)
Ask him on exit, if he wants to save the changes. Maybe he did some changes by mistake, which you don't want to save.
You can achieve this by Javascript/Jquery. Something like:
$(document).ready(function() {
formmodified=0;
$('form *').change(function(){
formmodified=1;
});
window.onbeforeunload = confirmExit;
function confirmExit() {
if (formmodified == 1) {
return "New information not saved. Do you wish to leave the page?";
}
}
$("input[name='commit']").click(function() {
formmodified = 0;
});
});
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a document (xml) where each line has a format like this
<Field ID="{475c2610-c157-4b91-9e2d-6855031b3538}" Name="FullName" DisplayName="Full name" Type="Text" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="FullName" ColName="nvarchar6" Required="FALSE" Hidden="TRUE" ReadOnly="FALSE" PITarget="" PrimaryPITarget="" PIAttribute="" PrimaryPIAttribute="" Aggregation="" Node="" />
The properties ColName="<>" and ID="{<>}" are supposed to be unique for every line that exists in the document.
How can I loop through each line and and see if the values inside ColName and ID appears more than once(preferrably though C#)?
Treating it like code golf... to get duplicate elements:
var duplicateElements = XDocument.Load(pathToDocument).Root.Elements()
.GroupBy(el => String.Format("{0}|{1}", el.Attribute("ID").Value, el.Attribute("ColName").Value)))
.Where((val, e) => val.Count() > 1);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am updating the values in grid view. if i am updating the noofdays it will showing Input string was not in a correct and how to give me some suggestion.
and i have other question when the employee apply leave before week it will take the data else it will show the message.
how to write it logic.
code behind
leaveUpdateRow.NoOfDays = Convert.ToInt32(((TextBox)(row.Cells[4].Controls[0])).Text);
ASPX
<asp:BoundField DataField="NoOfDays" HeaderText="Leave Period"></asp:BoundField>
Try this
leaveUpdateRow.NoOfDays = Convert.ToInt32(((TextBox)(row.Cells[4].Controls[0])).Text) == NULL ? 0 :Convert.ToInt32(((TextBox)(row.Cells[4].Controls[0])).Text);
Try it
please check the value is integer before convert the values.
Use string.IsNullOrEmpty
leaveUpdateRow.NoOfDays=string.IsNullOrEmpty(((TextBox)(row.Cells[4].Controls[0])).Text)?0:Convert.ToInt32(((TextBox)(row.Cells[4].Controls[0])).Text);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have simple form with Post request to page. When user clicks the subscribe button he comes to the page, where I would like to have information about where it come from. I have tested it using small site, to make sure I have redirect..
Request.UrlReferrer and ServerVariables["HTTP_REFERER"] is NULL
IP and all other data is in place.
How do i find the Url, Form was posted to my page from ?
Form designed to be embedded on any site/page with simply copy/paste.
Thanks.
Another SO user has reported that HTTP_REFERER doesn't get populated in posts across domains.
So I think it would be better to rely on JavaScript to populate a hidden input in your form with the referring page just before submission. Something like this:
<form action="http://www.yourdomain.com/subscribe"
method="POST"
onsubmit=
"document.getElementById('www.yourdomain.com.referrer').value=window.location;" >
<!-- hidden input for field starts with a domain registered by you
just so that it's unlikely to clash with anything else on the page -->
<input type="hidden" id="www.yourdomain.com.referrer" name="referrer"/>
your email: <input name="email" type="text"/>
... rest of form ...
<input type="submit" value="Subscribe"/>
</form>
Then you can get the referring URL from Request.Form["referrer"] in the handling page.