0

I want to make send a parameter and redirect to another page in another website using asp.net webforms programmatically please help.

I have this in code behind and I dont know how to inject it to page?

string postRefIdScript = @" <script language='javascript' type='text/javascript'> function postRefId (refIdValue) { var form = document.createElement('form'); form.setAttribute('method', 'POST'); form.setAttribute('action', '" +PgwSite +@"'); form.setAttribute('target', '_self'); var hiddenField = document.createElement('input'); hiddenField.setAttribute('name', 'RefId'); hiddenField.setAttribute('value', refIdValue); form.appendChild(hiddenField); document.body.appendChild(form); form.submit(); document.body.removeChild(form); } </script>"; 
1

2 Answers 2

1

It's easy enough to register a JS block from code behind. Just add the following line of code after assigning your postRefIdScript variable.

Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "mykey", postRefIdScript); 
Sign up to request clarification or add additional context in comments.

Comments

0

Add it to to url before redirecting. For example , example.com/siteinfo.aspx?param1=value&param2=value2

1 Comment

this make a get request and I want a Post Request and then redirect.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.