Add a aspx page value to a postbackurl querystring

peter liles 556 Reputation points
2021-09-13T14:17:52.333+00:00

How do you include a value assigned to a hidden element to a button Postbackurl. I have attempted the following code without success?

PostBackUrl='String.Format("~/MyProject/AdminManager - Copy/Messaging/Pictures.aspx?id={0}", <%=MessageID.Value %>)'

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,252 questions
{count} votes

Accepted answer
  1. Lan Huang-MSFT 25,471 Reputation points Microsoft Vendor
    2021-09-14T09:05:17.21+00:00

    Hi @peter liles ,
    First, you need to pass the value to confirm whether the MessageID has a value.
    I suggest that you can use Request.QueryString to accept a collection of URL query strings.

    PostBackUrl='<%# String.Format("~/MyProject/AdminManager - Copy/Messaging/Pictures.aspx ?id={0}", Request.QueryString["MessageID"]) %>'  
    

    Best regards,
    Lan Huang


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful