Solved

Best way to update a web page in VB 2010 using ASP.net 4.0

Posted on 2011-03-09
9
479 Views
Last Modified: 2012-06-21
I am new to ASP.net development and would like some opinions on the recommended ways to update/refresh a web page without doing a full reload of the page from the server.  I want to avoid the screen flash as much as possible.  I also want to stay with Microsoft products where possible.

Thank you for the suggestions and guidance.
0
Comment
Question by:EYoung
  • 5
  • 3
9 Comments
 
LVL 5

Assisted Solution

by:mayankagarwal
mayankagarwal earned 100 total points
ID: 35085418
you can use ajax update panel for the same
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 35085503
The use of UpdatePanels, or JQuery will give you that just depends on what you want really.

Samples using UpdatePanel:

    http://msdn.microsoft.com/en-us/library/bb399001.aspx
0
 
LVL 7

Author Comment

by:EYoung
ID: 35085967
Thank you for the suggestions.

I have tried to follow the directions in the url provided but am getting some errors.  I should say that the web site I have developed uses MasterPages for controlling the headers, footers, and menus on the various web site pages.

I want to change an image on the Control pages when the user clicks a MasterPage menu option.  Is that possible using Ajax client side controls?

When I add the Ajax ScriptManager and UpdatePanel controls to the Default.aspx form (which is a Content page under the MasterPage), I get an error saying that the Label and Button controls are not know elements.  Can Ajax controls be used on a Content page and run by clicking on one of the MasterPage menu options?  I am guessing that is not possible, nor does it make sense now that I am typing this out.
<%@ Page Language="VB" MasterPageFile="MasterPage.master" CodeFile="Default.aspx.vb" Inherits="_Default" Debug="true" %>

<asp:Content ID="Home1" ContentPlaceHolderID="Home" Runat="Server">   

    <asp:ScriptManager ID="ScriptManager1" runat="server">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <asp:Label runat="server" Text="Label"></asp:Label>
            <asp:Button runat="server" Text="Button" />
        </asp:UpdatePanel>
    </asp:ScriptManager> 

    <div style="position:absolute; top:81px; left:833px; z-index: 1; visibility:visible; height: 20px; width: 290px;
        font-size:xx-large; color: Maroon" align="right">
        Home
    </div>    

    <div style="position:absolute; top:130px; left:823px; z-index: 1; visibility:visible; height: 20px; width: 300px; text-align:right;">
        <p><%= mWelcomeMessage%></p>
    </div>

    <div style="position:absolute; top:210px; left:285px; z-index: 1; visibility:visible; height: 122px; width: 135px;">
        <img alt="" src="Images/Flagship_Store_30.jpg""/>
    </div>
    
</asp:Content>

Open in new window

0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 400 total points
ID: 35086024
The controls need to go inside the <ContentTemplate> and <ScriptManager> is a separate element:
    <asp:ScriptManager ID="ScriptManager1" runat="server" />

    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
        <ContentTemplate>
            <asp:Label runat="server" Text="Label"></asp:Label>
            <asp:Button runat="server" Text="Button" />
        </ContentTemplate>
    </asp:UpdatePanel>

Open in new window

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 7

Author Comment

by:EYoung
ID: 35086204
OK, I see.  Thank you.

Instead of having the user click the Button1 Ajax control on the web page, is it possible to have the user click a menu item on the MasterPages menu to change something on the web page?  I like the idea of MasterPages as it seems to make the coding easier without having to duplicate the same menus on all the web pages.
<%@ Page Language="VB" MasterPageFile="MasterPage.master" CodeFile="Default.aspx.vb" Inherits="_Default" Debug="true" %>

<asp:Content ID="Home1" ContentPlaceHolderID="Home" Runat="Server">   

    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
        <ContentTemplate>
            <asp:Label ID="Label1" runat="server" Text = "" style="position:absolute; top:81px; left:833px; z-index: 1; visibility:visible; height: 20px; width: 290px;
                font-size:xx-large; color: Maroon" align="right"></asp:Label>
            <asp:Button ID="Button1" runat="server" Text="Button" />
        </ContentTemplate>
    </asp:UpdatePanel> 

    <div style="position:absolute; top:130px; left:823px; z-index: 1; visibility:visible; height: 20px; width: 300px; text-align:right;">
        <p><%= mWelcomeMessage%></p>
    </div>

    <div style="position:absolute; top:210px; left:285px; z-index: 1; visibility:visible; height: 122px; width: 135px;">
        <img alt="" src="Images/Flagship_Store_30.jpg""/>
    </div>
    
</asp:Content>

Open in new window

0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 35086374
You can add triggers to the update panel to indicate which controls should cause the update panel to redraw. You would need to change your update panel to something like:
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:Label ID="Label1" runat="server" Text = "" style="position:absolute; top:81px; left:833px; z-index: 1; visibility:visible; height: 20px; width: 290px;
                font-size:xx-large; color: Maroon" align="right"></asp:Label>
            <asp:Button ID="Button1" runat="server" Text="Button" />
        </ContentTemplate>
        <Triggers>
              <asp:AsyncPostBackTrigger ControlID="ID_Of_Your_Menu" />
        </Triggers>
    </asp:UpdatePanel>

Open in new window

0
 
LVL 7

Author Closing Comment

by:EYoung
ID: 35086383
Please ignore my last post.  I need to rethink what I am trying to achieve before asking questions.  The Ajax controls now work and that is what I was looking for.  Thank you for the quick responses.
0
 
LVL 7

Author Comment

by:EYoung
ID: 35086400
Thank you carl_tawn.  Much appreciated.
0
 
LVL 7

Author Comment

by:EYoung
ID: 35086656
carl_tawn:

Can you also look at this question?  It is a followup one.

Thanks

http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_26875076.html
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now