I have a ASP.Net 2.0 web app in VB. I need to copy all relavant data for the current customer shown on the page from a menu action item. Then when the action has completed the copy methods, with a new Unique reference ID, I need to reload the same page with the relavant data of the new unique ID.

For instance,I have a contract for renewal. I open the contract and all the relavant data is diplayed. I select renew contract from a menu item and it calls the mehods to copy all the original data and creates a new unique contract ID. Once the copy is complete, the same page is reloaded with the new uniqueID and newly created data.

I have created all the copy procedures and fire them with the menu item. I am used to using Reponse.Redirect to open another form, but how do you re-open the same form with new information?

Dani AI

Generated

: the cleanest, safest pattern for your flow (open contract -> copy -> show new contract) is Post-Redirect-Get. and are on the right track pointing at doing a redirect back to the same page with the new contract identifier, but the important part is why and how to do it reliably so the copy does not run twice and the browser shows the new data as a fresh GET.

Do the copy server-side, confirm the DB transaction completes and that you have the new ID, then issue a redirect so the browser requests the page using that new ID. This gives you a single, bookmarkable URL for the new contract and avoids duplicate copies if the user refreshes or uses the back button. In your page load logic, treat the incoming ID as a GET parameter: validate it, use parameterized queries, and only bind the detail data when handling the GET (avoid re-running the copy on postback).

Troubleshooting and cautions: log the returned new ID to verify the copy succeeded before redirecting; handle failures gracefully (show an error instead of redirecting); sanitize and validate the ID to avoid injection or accidental exposure; if the ID is sensitive consider a temporary token or server-side session mapping instead of exposing raw DB keys. If the copy is long-running, run it asynchronously and show status/disable the menu to prevent multiple clicks. Server.Transfer can preserve context but is rarely what you want here because it does not create a fresh GET; prefer issuing a real redirect for clarity and robustness.

Recommended Answers

All 3 Replies

Hello!
i didn't understand what you want but i can suggest to use response.redirect to the same page with querystring.
Best Regards!

That sounds like what I need, just not sure how.

Code looks like this.

Protected Sub MenuNav_MenuItemClick

  Select Case MenuNav.SelectedItem.Text

  Case "Create Renewal"
   Dim ContractID as Integer
   CopyContract(mwus.ContractID)

   ContractID = GetRenewalID()

   Response.Redirect("..\frmContract.aspx", False)

End Sub

if you are on process.aspx?id=124&param2=val2 and after the post back you want to redirect to process.aspx?id=982&param2=val2 yu can simply use

Response.Redirect("process.aspx?id="+var_id+"&param2="+var_param2value)

which i believe you already know but dont wanna do....
if you dont want to hard code the page name ( process.aspx ) then you can use Request.Path which will return you the page name i.e: "/process.aspx" without any querystring parameters.... you can append the parameter values later on the way you want.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.