NUnitAsp

WebFormTester.PostBack Method (String)

Emulates ASP.NET's post-back script (often seen as a Javascript "__doPostBack" call). To simply submit the form, use Submit instead. If you don't have access to the JavaScript call, use PostBack instead. This method throws an exception if the postBackScript string isn't actually a post-back script (for example, if it's an empty string). Use OptionalPostBack if the string isn't expected to contain a post-back script all of the time.

public void PostBack(
   string postBackScript
);

Example

ASP.NET LinkButtons are rendered as <a> hyperlinks with a post-back script call in the "href" attribute. The following code takes the call from the attribute and calls PostBack(), causing NUnitAsp to analyze the post-back script call, set the appropriate environment variables, and submit the form.

            string href = Tag.Attribute("href");
            Form.PostBack(href);
            

See Also

WebFormTester Class | NUnit.Extensions.Asp Namespace | WebFormTester.PostBack Overload List