question

peterliles-4155 avatar image
0 Votes"
peterliles-4155 asked LanHuang-MSFT answered

Add a aspx page value to a postbackurl querystring

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 %>)'

dotnet-aspnet-webforms
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Set the PostBackUrl in the code behind. I question the use of a hidden field since you need to know the MessageID to populate the hidden field in the first place.

 Button1.PostBackUrl = String.Format("~/MyProject/AdminManager - Copy/Messaging/Pictures.aspx?id={0}", MessageID.Value);
1 Vote 1 ·

1 Answer

LanHuang-MSFT avatar image
0 Votes"
LanHuang-MSFT answered

Hi @peterliles-4155,
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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.