.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Clearing ValidationSummary when form returns a download request

Posted By:      Posted Date: September 20, 2010    Points: 0   Category :ASP.Net


Here's my setup:

Simple mvc page with a few controls that includes a validation summary area. 

Once the fields are completed there's a download button.

If I enter something invalid, as expected, my controller code updates the UI with the appropriate error.  However, if I then correct the error, and then click the download button a file is downloaded, but the UI never gets updated - presumeably since there's no update on the view.

Any ideas on a way around this - perhaps some javascript code.  Just wondering what's the best practice here?


View Complete Post

More Related Resource Links

Unwanted form clearing

Hi all, Some users have somtetimes problem with unwanted reload and clearing form after they do some action. For instance they fill grid with some data then click "add another position" and form reload and lose its data. There is no rule cuz they can add 10 position and on 11 the error occur or even 100 and on 101 the error appear. The form looks as you click "CTRL + R" or go to it again through menu.  This is not only one form but generally it may appear on all forms. Any ideas what may cause this error? I am not sure if it is a WCF problem but on other apps I have't noticed such a problem.

Difficult in using Request.Form

Hi all,i just try to pass value between pages using Request.Form,Here the scenario,1.First i created a two aspx pages(First.aspx and Second.aspx), First.aspx is a main page and Second.aspx is a popup.2.in the main page i created a button with type submit and text box , and in the button  onclick i call a function in the javascript which open the popup page3.When i try to retrieve the values from the main page in the popup i can't retrieve the valuesHere the codeFirst.aspx=========================================================<script language="javascript"> function fnClear() {window.open("Second.aspx","sendvalue","height=350,width=700,scrollbars=1");                }</Script><form id="mainpage" name="mainpage" method=post runat="server"><input type="text" name="txtStDate" runat="server" tabindex="1"                                                                                                 id="txtStDate" maxlength="

AJAX Form POST Request to a DLL Problem

I am using AJAX javascript for POSTING a complete HTML form to the server which is an external dll on a different server and displaying the response. The server-response is displayed in a "div" . basically i need to show a poll in a .aspx page which is basic a question with 3 options & a button. Now on click of submit button i need to post the data to a dll & show the result from the dll itself. Any idea how to do this? is it possible..any code???

Leave Request Form


I now have recreated my Leave request form in sharepoint designer and just need a few pointers.

Ill explain what i have first.

I have a document libary call time-off request here users can fill out a word template requesting leave they fill out the following fields.

Employee Name, Start Date: Return Date: Type Of Holiday

Once they have saved this back to the libary the workflow starts it marks the status of the request to open it then copys the item into a new list called Time-Off Request Status and then deletes the item in the Time Off Request List finally it emails the manager of that employee telling them to approve or reject the request in the the Time Off Request status libary.

There is another workflow attached to the Time Off Request status libary where if the manager approves the request it sends an email to that user and updates days remaing in a final list called annual leave remaining.

The problem that i have is any user can go into the Annual Leave remaining list and change the number of days that they have left however i need them to have the contribute permission so the workflow can update the list.

I asked a similar question back when i created this in Sharepoint Services  3.0 and was told something about impersonating work flow steps but i am unsure of how to do this.

Also the workflow does no

wcf 4 rest service accepts xml and json posts but get 400 bad request on form post


Using the rest 4 template.  I have a POST method defined, with an object as a parameter.  REST 4 does a great job of automatically mapping both xml and json posts to the method.  I tested this using an HttpClient test application to build and post xml content and then json content.  All data gets correctly mapped to the corresponding properties in my entity. 

I want to also support a standard form post to the method but am having problems! 

I'd like the same method already accepting and converting both xml and json to also work correctly for a form post.  I figured it would "just work" but no.

I am testing this by creating an HttpUrlEncoded form in the test client, adding form name/value pairs that match what the method is expecting, and trying to post it.

However I get a 400 Bad Request.  Here's some example code that is returning a 400 bad request:

Really straightforward but fails.  Ideas why? 


      var client = new HttpClient();

      HttpUrlEncodedForm form = new HttpUrlEncodedForm();
      form.Add("Id", "99"<

use infopath form for request and appoval



i have created an infopath form. when the user submit this request form to the specific approver a mail will be sent to the specific approver.

now i want that when the approver open this form, the fields that the user had filled must be read only and the approver section must not be read only. the appover must be able to approve the form and submit the same form to the hr.

the approver section has a dataview list where the approver can choose if the request is approved or rejected.

i know i can use a workflow, but if i use a workflow can the workflow send the request to the specific approver of each user?

cause in my form when the user open the form there is a field that is filled with the specific approver of the user. and when the user click on the submit button the form will be send by mail to the specific approver.



A potentially dangerous Request.Form value was detected from the client


I know this has been discussed already but my problem isn't the error itself. My problem is I am including [ValidateInput(false)] above my ActionResult and I still receive this error when I click submit. Is there something somewhere else overriding this command?

Here is what the code looks like.

[Authorize(Roles = "Administrator")]
        public ActionResult Create(FormCollection Form)

[Authorize(Roles = "Administrator")]



userName() function returns the original form author on alternate view

I am working with an InfoPath 2010 form using web forms (SharePoint InfoPath Forms Services).  The form has two views.  The first view for submitting a "Project" and another view for users to comment on that project.  There is one field (ProjectAuthor) which records the original author using the userName() function.  On the second view, I have another field (CommentAuthor) also set to use the userName() function to record the person making the comment.  When that second view is opened by a different user, the original author of the form is populated in that field and not the commenter.  I have tried both checking and unchecking "Refresh value when formula is recalculated" but that does not change the value.

Help! Can't find dynamic button's postback in page.request.form??


Okay, I know that dynamic buttons and buttons in general don't use a typical postback and they post through the page.request.form.  Okay, so in visual studio, I was able to determine that page.Request.form and in the all-keys property, i SEE my button there.  It is the last item in all-keys.

When I am clicking this dynamic button which is in an updatepanel, the script below does not detect it as a button, it is still showing it as null:

public static Control GetPostBackControl(Page page)

            Control control = null;
            string ctrlname = page.Request.Params.Get("__EVENTTARGET");
            if (ctrlname != null && ctrlname != string.Empty)
                control = page.FindControl(ctrlname);

Get CssClass value using Request.Form


Hi all,

Is it possible to get the CssClass and SkinID via Request.Form? 

I tried below but failed.

Dim i As Integer
        Dim itemName As String
        Dim itemValue As String

        For i = 0 To HttpContext.Current.Request.Form.Count - 1
            itemName = HttpContext.Current.Request.Form.AllKeys(i)
            'itemValue = HttpContext.Current.Request.Form.GetValues(i)(0)
            itemValue = HttpContext.Current.Request.Form.Get("CssClass")


Clearing a form with response.redirect


I have the following default.aspx.vb

Imports System.Data.SqlClient
Imports System.Data

Partial Class _Default
    Inherits System.Web.UI.Page
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    End Sub
    Public Sub InsertRow()
        Dim myConnectionString As String = "Initial Catalog=mdr;Data Source=xxxxxxx;uid=xxxxxx;password=xxxxxxxx;"

        Dim myConnection As New SqlConnection(myConnectionString)
        Dim commandText As String = _
        "insert into Exceptions (employeenumber, exceptiondate, starttime, endtime, duration, code, approvedby) " & _
        "values(@employeenumber, @exceptiondate, @starttime, @endtime, @duration, @code, @approved)"

        Using connection As New SqlConnection(myConnectionString)
            Dim command As New SqlCommand(commandText, connection)

            command.Parameters.Add("@employeenumber", SqlDbType.VarChar)
            command.Parameters("@employeenumber").Value = OperatorDropdown.SelectedItem.Text

            command.Parameters.Add("@exceptiondate", SqlDbType.DateTime)
            command.Parameters("@exceptiondate").Value = exceptiondateInput.Text

            command.Parameters.Add("@starttime", SqlDbType.DateTime)

A potentially dangerous Request.Form value was detected from the client



i have a form that use can insert some text in textbox

if user insert <..> page return an error like

A potentially dangerous Request.Form value was detected from the client 

the problem is i need to user inter some html code that's because i change the code in web.config file

<pages validateRequest="false"

URGENT!!, A potentially dangerous Request.Form value was detected from the client



I get mails about an unhandled error has occurred:
Message: A Potentially Dangerous Request.Form value was detected from the client (ctl00 $ default master content $ txtCustomerMessage ="... ???????? <a href = "http://aovo ...").

 Stack Trace:
   at System.Web.HttpRequest.ValidateString (String s, String Value name, String collection name)
   at System.Web.HttpRequest.ValidateNameValueCollection (name value collection nvc, String collection name)
   at System.Web.HttpRequest.get_Form ()
   at System.Web.HttpRequest.get_HasForm ()
   at System.Web.UI.Page.GetCollectionBasedOnMethod (Boolean dontReturnNull)
   at System.Web.UI.Page.DeterminePostBackMode ()
   at System.Web.UI.Page.ProcessRequestMain (Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest (Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.AsyncPageProcessRequestBeforeAsyncPointCancellableCallback (Object state)
   at System.Web.HttpContext.InvokeCancellableCallback (wait callback callback, Object state)
   at System.Web.UI.Page.AsyncPageBeginProcessRequest (HttpC

Accessing response of HttpWebRequest, even when request returns 500 Internal Server Error



Hoping someone can point me to a solution, haven't been able to find one yet.

I'm using the standard way for send HttpWebRequest

		webRequest = (HttpWebRequest)WebRequest.Create(request.URL);
webRequest.Method = "POST";
webRequest.ContentType = "text/xml";


postStream = webRequest.GetRequestStream();
postStream.Write(requestBuffer, 0, requestBuffer.Length);
webResponse = (HttpWebResponse)webRequest.GetResponse();
responseStream = webResponse.GetResponseStream();
responseReader = new StreamReader(responseStream);
string response = responseReader.ReadToEnd();

This is all fine, working correctly, no poblems.

However the actual webservice that i'm calling returns a 500 Internal Server Error code for standard faults

HTTP/1.1 500 Internal Server Error
Content-Type: text/xml; charset=utf-8
Content-Length: 703
Date: Fri, 22 Oct 2010 04:50:48 GMT

<?xml version="1.0" en
coding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.o

A potentially dangerous Request.Form value was detected from the client


I am getting the above error when I am trying to save a value '<TS1'. I did the search and came to know it is about html injection. So I entered ValidateRequest="false" on top of the page and in the code behind file I have the following code.

Protected Sub fvAddCompass_ItemInserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewInsertEventArgs) Handles fvAddCompass.ItemInserting

Dim strProvided A

How to get request.form working in masterpages?

Hi all,

On pages that use masterpages, request.form always return null. It works fine on pages without masterpage. Is this normal? How to use request.form in pages with masterpages?

Thanks in advance.

Request Failed Infopath Form


Hi All,

My requirment is to save infopath form values to sharepoint list.

I have created form and button for coding


 public void CTRL11_5_Clicked(object sender, ClickedEventArgs e)
            // Write your code here.
                XPathNavigator root = this.MainDataSource.CreateNavigator();
                string EmpID = root.SelectSingleNode(("/my:myFields/my:txtEmpID", NamespaceManager).Value;
                string EmpName = root.SelectSingleNode("/my:myFields/my:txtEmpName", NamespaceManager).Value;
                string EmpDesignation = root.SelectSingleNode("/my:myFields/my:ddlEmpDesignation", NamespaceManager).Value;

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend