Tech Off Thread

4 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

HELP ME PLEASE!

Back to Forum: Tech Off
  • User profile image
    z2bass

    Hi. I am doing some stuff in ASP.net 2.0 and im kinda new at this. I am a hardcore windows dev and now im doing a website. so does anyone know how to change pages from code-behind? if you could email me at zowens@eagleenvision.net

    i would appricate any help!

    zack

  • User profile image
    littleguru

    First you need to create the markup (html). Then you can access from codebehind by giving the element an ID and add the runat="server" attribute. You may also use the asp.net components in the html.

    Example:

    markup:
    <a href="#" id="coolLink" runat="server">This is a cool link</a>

    code:
    coolLink.Href = "http://www.opf3.com/";


    Using the asp.net link:

    markup:
    <asp:LinkButton id="coolLink" PostBackUrl="http://www.opf3.com" runat="server">LinkButton</asp:LinkButton>

    code:
    coolLink.PostBackUrl = "www.foo.com";

    You could also read a book on ASP.NET: http://www.amazon.com/gp/product/0735621764/sr=8-2/qid=1154850713/ref=pd_bbs_2/104-6127655-6307132?ie=UTF8


    Btw. Changing the title to something more meaningful wouldn't be that bad!

  • User profile image
    Coding​Obomination

    Your question is a bit unclear. When you say "change a page from a code-behind" do you mean you want to dynamically change the content genererated at a specific page or do you want to go to another page.

    If you are looking for help on how to change the content generated by a page, you need to spend some time reading a book on asp.net or perhaps reading the background artices on MSDN.

    If you  want to go to another page you have two choices:

    1) Server.Transfer([url of the page you want to go to], true)

    2) Response.Redirect([url of the page you want to go to])

    In most cases you'll want to use option 2, but not in all cases.

  • User profile image
    z2bass

    thanks!

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.