RemH 0 Newbie Poster

Hi Everybody,

I Just started C# and have an issue with this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace testurl
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        public void Page_Load(object sender, EventArgs e)
        {

        }

        public void Button1_Click(object sender, EventArgs e)
        {

            string Url = "mysitename.org";
            var uriBuilder = new UriBuilder(Url);

            uriBuilder.Scheme = Uri.UriSchemeHttps;
            uriBuilder.Port = -1;

            var query = HttpUtility.ParseQueryString(uriBuilder.Query);
            query["secret"] ="whatever";
            query["u"] = "67";
            uriBuilder.Query = query.ToString();
            Url = uriBuilder.ToString();

            Response.Write("<b>De te gebruiken URL:</b> " + Url);

        }

        public void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {

            //Here I want to call the url generated by the button click

            Response.Redirect(url);

        }
    }
}

I tried to create an private string outside, but then it is empty (Null)
or one trie I got the message object moved to here.

How do I pass the variable url to the imagebutton click?

Thanks

Rem

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.