Hidden inputs are missing from Request in Asp.net mvc3 - ajax

I'm using asp.net mvc3 ajax.beginform, and recently I've encountered a very strange problem.
It seems that some of the hidden input's I've placed inside the form do not exist in the request object.
I am not changing these values in any way after the post.
Any idea what is the reason?
Here's an example of a form that's giving me some trouble.
<form action="/PriceListItems/PriceUpdate" data-ajax="true" data-ajax-method="Post" id="form0" method="post">
<input id="item_Id" name="item.Id" type="hidden" value="3">
<input id="price_TariffId" name="price.TariffId" type="hidden" value="1">
<input class="input-mini"
data-val="true"
data-val-number="The field Price must be a number."
data-val-regex="incorrect number"
data-val-regex-pattern="(^N/A$)|(^[-]?(\d+)(\.\d{0,3})?$)|(^[-]?(\d{1,3},(\d{3},)*\d{3}(\.\d{1,3})?|\d{1,3}(\.\d{1,3})?)$)"
data-val-required="שדה זה הינו חובה"
id="itemTariff_3_1"
name="price.Price"
onchange="postThis(this);"
type="text"
value="300.00">
<span class="help-block">
<span class="field-validation-valid"
data-valmsg-for="itemTariff_3_1"
data-valmsg-replace="true"></span>
</span>
</form>
Thanks!
solved it, but it was quite a disappointing solution..:
i've replaced every jquery related script in my site so that it'll arrive from a CDN rather from my local files, but in the original versions.
and that was it.
everything suddenly started to click together.
frustrating, but works.
thanks,
Nir

Related

How do I emulate a button press in web scraping?

Hello I am using colly to scrape my university's classes. The web page is simple enough
<form id="rngID" method="post" action="../../../SOME_REALLY_LONG_PATH">
<input type="hidden" name="rngID_hf_0" id="rngID_hf_0">
<label for="user">User:</label>
<input type="text" maxlength="20" value="" name="user" class="required valid">
<label for="password">Password:</label>
<input type="password" maxlength="20" value="" name="password" class="required valid">
<input type="hidden" id="js" value="1" name="js" class="valid">
<script>
/*<![CDATA[*/
document.getElementById("js").value = "1"
/*]]>*/
</script>
<input type="submit" class="btn-blue valid" name="login" id="rngID+2" value="Ingresar">
</form>
I find myself needing to interact with the website's contents. I understand I have the underlying objects associated to the HTML file recieved, but I am struggling to find how to trigger the submit action. Moreover I am unsure how to set the html input values with colly (username and password).
Can this not be done in colly? It seems to have good cookie management which fits in what I'm looking fo
Colly doesn't resolve/render the HTML DOM to the same degree as a web browser in a few ways, but the most notable is that it doesn't interpret and run JavaScript. So there is no direct way to emulate button presses with it.
However, forms can be submitted through post requests and goColly supports this with the Post method for a collector.

Form input old value in laravel 5.6

I have a search form input where i want to display the searchterm value in the searchbox after searching on the results page.
I tried the following which is not working
<input type="text" name="search" value="{{ old('search') }}" placeholder="Search help articles" class="form-control form-control-gray col-md-10">
What is incorrect in the value=""
old() is used when flashing data to the session. This is mostly used for forms which involve redirects back when something fails. Read about old input here.
request() should be used here since you're wanting to display the value that was submitted on that request.

MethodNotAllowedHttpException in submitting equation format from form textarea (ckeditor)

Hi there I am submitting a equation from ckeditor and geting MethodNotAllowedException though my form has method type post and route also post.
Here is my view.
<form class="form-horizontal" action="{{route('set-question')}}" id="submit_form" method="post">
{{csrf_field()}}
<div class="col-md126 col-md-9 col-md-offset-1">
<label class="control-label">Question</label>
<p class="help-block" style="font-size:12px;">Question is required</p>
<textarea name="question" class="ckeditor"></textarea>
<input type="submit" class="btn btn-success" value="Submit">
</div>
</form>
If I type this or some other equation only then other problem arise. I have saved by typing other format even with bengali language that was good. Bellow is my route and then the typography I was able to save in db via this route and view.
Route::post('add-question','Admins\ExamController#addQuestion')->name('set-question');
The successful tries.
But after the highlighted equation or format i got MethodNotAllowedHttpException.
Please suggest me what I'm missing.
Thank you in advance.
You can clean your cache. Because i faced sometime this type of problem and after clean my cache it will be fine.
One thing you can try with name route like: name('set.question)

Custom comments template in BlogEngine

When someone wants to write a comment, It has to set Name, Email, Web Site and finally comments . How should I modify this template to use just the Comment? Because It has these info when admin registered him. I dont want to store false info.
Thanks for your help.
Since you didn't specify the version I am assuming you are running on the current latest (3.1).
The comment submission form is controlled by the CommentForm.cshtml in the siteroot/Custom/Theme/YourCurrentTheme folder. Here is a portion of the form from the Garland-Revisited theme.
<p>
<label for="txtName" class="lbl-user">#Resources.labels.name *</label>
<input type="text" class="txt-user" name="txtName" id="txtName" />
</p>
<p>
<label for="txtEmail" class="lbl-email">#Resources.labels.email *</label>
<input type="text" class="txt-email" id="txtEmail" />
</p>
<p id="commentCompose">
<textarea class="txt-content" id="txtContent" cols="50" rows="10" name="txtContent"></textarea>
</p>
The simplest path is probably to avoid changing the submission handler and convert the input type to hidden and prefill the value with their logged in credentials. A possible sample.
<input type="hidden" id="txtName" value="#SomeC#CodeToReadTheValuesFromTheLoggedInInformation" />
<input type="hidden" id="txtEmail" value="#SomeC#CodeToReadTheValuesFromTheLoggedInInformation" />
<p id="commentCompose">
<textarea class="txt-content" id="txtContent" cols="50" rows="10" name="txtContent"></textarea>
</p>
This does have security implications. You are trusting your users not to mess with the hidden values in the form. On an open website this probably isn't safe enough and you will have to look at changing the submit handler.
Changing the submit handler does have its own maintenance issues since you will be running a custom version of the software that won't upgrade cleanly when the next version comes out. It's up to you to decide what is the better path in your situation.

File Upload in Servlets

Hi I have a form having upload file and an input type="text".
<input type="file" id="uploadFile" name="file" required="required">
<input type="text" id="purpose" name="purpose" required="required">
Now when the user clicks the button I want to hit a servlet through AJAX and set the file to a required folder and also retrieve the purpose input value and put it in my table.
Any help how can I achieve this ?
I encountered with this problem yesterday. As developerwjk said, I used:
commons-fileupload.jar
commons-io.jar
For more information see this useful question.

Resources