Ajax postback problem

Discussion in 'ASP.NET 2.0' started by mykeparker, Mar 3, 2007.

  1. Hi, I have been searching the internet for a couple of hours and cannot find the solution and read over and over my code and still no luck.

    Problem: I have built a website and on one of the pages added Ajax functionality. I have included the scriptmanager and updatepanel on the page and it all works fine in Visual Studio 2005. But when I upload it to DiscountASP it does a full page postback rather than a partial.

    I do not know if this is relevent but the scriptmanager and updatepanel tags are underlined with message: 'Element 'ScriptManager' is now a known element. This can occur if there is a compilation error in the website'

    Another thing If I do a really simple webpage with a button in the updatepanel and one without with the date and time on to test whether the page is being updated it works. So i guess its something wrong with my page.

    Please help I really need this working. Many thanks Mike

    Code Dashboard.aspx:

    <%@ Page Language='VB' MasterPageFile='~/MasterPage.master' AutoEventWireup='false' CodeFile='Dashboard.aspx.vb' Inherits='secure_dashboard' title='The Web Generator | DashBoard' %>
    <asp:Content ID='Content2' ContentPlaceHolderID='MainBodyContentPlaceHolder' Runat='Server'>
    <asp:Label ID='Label1' runat='server' Visible='False' CssClass='msgimportant'></asp:Label>
    <table cellpadding='2' style='width: 100%' summary='Dashboard Table'>
    <tr>
    <td align='left' colspan='3' style='background-color: #ffffcc; text-align: center;' valign='top'>
    <asp:LoginName ID='LoginName1' runat='server' />'s Dashboard (<asp:LoginStatus ID='LoginStatus1' runat='server' LogoutPageUrl='~/Default.aspx' LogoutAction='Redirect' />)</td>
    </tr>
    <tr>
    <td align='left' colspan='3' valign='top'>
    <asp:ScriptManager runat='server'>
    </asp:ScriptManager>
    <asp:UpdatePanel runat='server'><contenttemplate>
    <asp:Label ID='LabelMessage' runat='server' Text='Label'></asp:Label>
    <asp:Label ID='LabelHistory' runat='server' Text='Label'></asp:Label></td></contenttemplate></asp:UpdatePanel>
    </tr>
    <tr>
    <td align='left' colspan='3' class='dark' valign='top'>
    Site creation and editing tools</td>
    </tr>
    <tr>
    <td align='left' style='width: 100px' valign='top'>
    <p><a href='CreateNewPage.aspx'>
    Create new page</a></p></td>
    <td align='left' style='width: 100px' valign='top'>
    <p><a href='CreateNewMenu.aspx'>Edit your menu page</a></p></td>
    <td align='left' style='width: 100px' valign='top'><p><a href='Themes.aspx'>Web page template styles</a></p></td>
    </tr>
    <tr>
    <td align='left' colspan='3' valign='top'>
    </td>
    <tr>
    <td align='left' colspan='3' class='dark' valign='top'>
    Account management tools</td>
    <tr>
    <td align='left' style='width: 100px' valign='top'>
    <p><a href='ChangePassword.aspx'>Change Password</a></p></td>
    <td align='left' style='width: 100px' valign='top'>
    <p><a href='CloseAccount.aspx'>
    Close Account</a></p></td>
    <td align='left' style='width: 100px' valign='top'>
    </td>
    </tr>
    <tr>
    <td align='left' style='width: 100px' valign='top'>
    </td>
    <td align='left' style='width: 100px' valign='top'>
    </td>
    <td align='left' style='width: 100px' valign='top'>
    </td>
    </tr>
    <tr>
    <td align='left' colspan='3' class='dark' valign='top'>
    Your site</td>
    </tr>
    <tr>
    <td align='left' style='width: 100px' valign='top'>
    <p><a href='FileManager.aspx'>File manager</a></p></td>
    <td align='left' style='width: 100px' valign='top'>
    <p><a href='FileDownloadList.aspx'>Download your site</a></p></td>
    <td align='left' style='width: 100px' valign='top'>
    </td>
    </tr>
    </table>
    </asp:Content>
    <asp:Content ID='Content3' runat='server' ContentPlaceHolderID='RightContentPlaceHolder'>
    Text here
    </asp:Content> </font>


    code: Dashboard.aspx.vb


    Partial Class secure_dashboard
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    'START Success messages after activities have been carried out
    'Index of #
    '1 = Password change successful
    If Request.QueryString('msg') = 1 Then
    LabelMessage.Visible = True
    LabelMessage.Text = 'Your password has been successfully changed.'
    End If
    '/END Success messages after activities have been carried out


    ' Directory to store files in is checked to see if exists, if not creates
    Dim DIRECTORY_NAME As String
    DIRECTORY_NAME = 'FileSystem/' & User.Identity.Name

    If System.IO.Directory.Exists(Server.MapPath(DIRECTORY_NAME)) = True Then
    'Do not create a new one
    Else
    System.IO.Directory.CreateDirectory(Server.MapPath(DIRECTORY_NAME))
    End If


    'Version information
    Dim history As String
    history = Request.QueryString('history')

    LabelMessage.Text = '<p>This is version ' & System.Configuration.ConfigurationManager.AppSettings('VersionNumber') & ' of The Web Generator.</p>'
    If history = 'info' Then
    LabelHistory.Text = '<p><strong><a href=''dashboard.aspx''>Hide Version History</a></strong>' & _
    '<strong>0.5 beta</strong> - Enabled Ajax for this website.</p>'
    Else
    LabelHistory.Text = '<strong><p><a href=''dashboard.aspx?history=info''>Show Version History</a></p></strong>'
    End If
    '/end version information
    End Sub
    End Class



    Any help with this problem would be really appreciated.
     
  2. Where on your page you expect the AJAX functionality?I only see the the Page_Load here?Can you post your site's URL ?

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. Hi, I have fixed the solution it was due to a problem with my web.config file.

    With my code you can see I was expecting it to appear in the updatePanel on the aspx page (Below the scriptmanager). I presume you were looking at the code behind file you do not need anything in their for the Ajax.

    Many thanks though for a response.
     

Share This Page