title: Programmatically Changing hyperlink url in Crystal Reports aspx page
body: <p>I have a page that shows all of my crystal reports as shown below:</p>
  
  <p>These reports have a (sadly, hard coded) url formula in them that points to e.g <a href="https://myserver.bla.bla" rel="nofollow">https://myserver.bla.bla</a></p>
  
  <p>I want to, somehow, programatically look for instances of the url, and change them to something else (there are hundreds of these reports and there is not enough time right now to go in and change all the links).</p>
  
  <p>I have been looking around in the FieldObjects, but can't seem to figure out how to change their formatting formulas. when I look at reportdocument.fieldformulas, the url formatting formulas are not present.</p>
  
  <p>public partial class Report : System.Web.UI.Page
      {</p>
  
  <pre><code>    protected void Page_Load(object sender, EventArgs e)
      {
          iLogger logger = LoggingFactory.CreateLogger();
  
          ReportDocument rd = new ReportDocument();
  
          string fileName = Request.QueryString["reportfile"];
  
  
          if(!Regex.IsMatch(fileName,@"^[ 0-9a-zA-Z-_\\]+.rpt$"))
          {
              ArgumentException aex = new ArgumentException("Invalid file/path specified.");
              logger.LogError(ActionTypes.Administration, HttpContext.Current.User.Identity.Name,
                              "Passed invalid file path to report viewer: " + fileName, aex);
              throw aex;
          }
  
  
  
          if(Path.IsPathRooted(fileName))
          {
              ArgumentException aex = new ArgumentException("Absolute path passed to report viewer.");
              logger.LogError(ActionTypes.Administration, HttpContext.Current.User.Identity.Name,
                           "Passed invalid file path to report viewer: " + fileName, aex);
              throw aex;
          }
  
          string rootPath = Server.MapPath("~/Reports/");
  
          string path = Path.Combine(rootPath, fileName);
  
  
  
          if (File.Exists(path))
          {
              rd.Load(path);
          }
  
          //get all keys starting with Prompt
          var prompts = Request.QueryString.AllKeys.Where(q =&gt; q.StartsWith("Prompt"));
  
          foreach (string promptKey in prompts)
          {
              //try to convert the rest of the string to an int  
              //yes, this should probably not just be a replace here...
                  string withoutPrompt = promptKey.Replace("Prompt", "");
  
                  int promptVal;
                  if (int.TryParse(withoutPrompt, out promptVal))
                  {
                      rd.SetParameterValue(promptVal, Request.QueryString[promptKey]);
                  }
                  //rd.SetParameterValue(promptKey, Request.QueryString[promptKey]);
  
          CrystalReportViewer1.ReportSource = rd;                        
      }
  }
  </code></pre>