Reputation: 113
I have a C# string that contains the answer to the question "May we contact?" How do I transfer that to our aspx webpage? The c# string is in the code behind page.
Upvotes: 0
Views: 726
Reputation: 34834
If you want to send the string to another page besides the code-behind it lives in, then use a query string entry to pass it to the URL you are redirecting to. If you want the current page to access the C# string, then make the string a protected
property so the page can use it an embedded code block.
Upvotes: 0
Reputation: 219096
If the string is a protected
(at least) property on the page then it can be accessed in the page's markup. So the string would be something like this at the class level:
protected string MyString { get; set; }
And in the page markup you can access its value:
<%= MyString %>
Upvotes: 3