asp.net built runtime Menu with offsite link
<p>I hope you can help me. First, I'd like to tell you I am a desktop app guy, which means I mostly develop my apps in desktop. Now I am trying to build some web app but it leads me to am not sure if confusion or just am doing it wrong.</p>

<p>I have a code here that it <strong>populates a menu at runtime</strong>. Runtime because they the menu items are populated at code behind and the items are fetched in database.</p>

<p>here's the code behind:</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        Menus menu = new Menus();
        imgMainLogo.ImageUrl = VARIABLES.MainLogoImage;
        menu.PopulateMenuControl(ref mainmenu, 2);
        menu.PopulateMenuControl(ref footermenu, 9);
    }
    else
    {
        System.Diagnostics.Debug.WriteLine("link: " + footermenu.SelectedValue);
        if (footermenu.SelectedValue != null)
        {
            Response.Redirect(footermenu.SelectedValue, true);
        }
    }
}
</code></pre>

<p>and the code in PopulateMenuControl</p>

<pre><code>public void PopulateMenuControl(ref Menu menucontrol, int menuparentid)
{
    //menucontrol.Items.Clear();

    foreach (MenuFields mf in GetMenusByParentID(menuparentid))
    {
        MenuItem menuitem = new MenuItem(mf.MenuName, ReplaceSystemNameLink(mf.Link));
        menucontrol.Items.Add(menuitem);

        foreach (MenuFields cmf in GetMenusByParentID(mf.MenuID))
        {
            MenuItem childmenuitem = new MenuItem(cmf.MenuName, ReplaceSystemNameLink(cmf.Link));
            menuitem.ChildItems.Add(childmenuitem);
        }
    }
}
</code></pre>

<p>So <code>Page.IsPostBack</code> is the very basic thing I should learn when doing something in a page. But the problem here is, one of my menu item in "footermenu" has an offsite link, and it should redirect the page into my blog.. but what's happening was, <code>footermenu.SelectedValue</code> is empty once I clicked on the "Blog" link. </p>

<p>What's going on?</p>

<hr>

<p>UPDATE</p>

<p>I have updated the code still stuck, the SelectedValue is still empty</p>

<pre>
protected void Page_Load(object sender, EventArgs e)
{
    System.Diagnostics.Debug.WriteLine("Page_Load IsPostBack: " + Page.IsPostBack.ToString());
    if (Page.IsPostBack)
    {
        if(footermenu.SelectedValue != null) 
        {
            System.Diagnostics.Debug.WriteLine("link: " + footermenu.SelectedValue);
        }
    }
}

protected void Page_Init(object sender, EventArgs e)
{
    System.Diagnostics.Debug.WriteLine("Page_Init IsPostBack: " + Page.IsPostBack.ToString());
    if (!Page.IsPostBack)
    {
        Menus menu = new Menus();
        imgMainLogo.ImageUrl = VARIABLES.MainLogoImage;
        menu.PopulateMenuControl(ref mainmenu, 2);
        menu.PopulateMenuControl(ref footermenu, 9);
    }
}
</pre>
