Wednesday, June 2, 2010

POST in asp.NET page without nesting forms

if (!IsPostBack)
{
ScriptManager.RegisterStartupScript(Page, this.GetType(), "postback", "function doExternalPost(targetUrl) { theForm.__VIEWSTATE.value = ''; theForm.encoding = 'application/x-www-form-urlencoded'; theForm.action = targetUrl; theForm.submit(); }", true);
}

litText.Text = string.Format("<input name="postInfo" value="{0}" type="hidden"><a onclick="\"javascript:doExternalPost('{1}');\"">clickme</a>", "prodABC" , "postURL");

No comments: