Click here to Skip to main content
15,860,844 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Can I get a hold of ASP controls in an ASPX page Pin
Abhishek Sur9-Nov-09 21:27
professionalAbhishek Sur9-Nov-09 21:27 
GeneralRe: Can I get a hold of ASP controls in an ASPX page Pin
fiaolle9-Nov-09 21:45
fiaolle9-Nov-09 21:45 
Questionchat application Pin
anishkannan9-Nov-09 6:36
anishkannan9-Nov-09 6:36 
AnswerRe: chat application Pin
Abhishek Sur9-Nov-09 7:14
professionalAbhishek Sur9-Nov-09 7:14 
GeneralRe: chat application Pin
N a v a n e e t h9-Nov-09 15:53
N a v a n e e t h9-Nov-09 15:53 
GeneralRe: chat application Pin
Abhishek Sur9-Nov-09 21:17
professionalAbhishek Sur9-Nov-09 21:17 
AnswerRe: chat application Pin
The Man from U.N.C.L.E.9-Nov-09 7:14
The Man from U.N.C.L.E.9-Nov-09 7:14 
QuestionASP.NET AJAX Postback Not Updating DOM? Pin
Shawn Souto9-Nov-09 5:55
Shawn Souto9-Nov-09 5:55 
Hello fellow coders,
I am having a strange problem which I've never run in to previously.

The Problem:
I am getting back the new HTML in the AJAX postback, but the DOM / page isn't updating.

How it happens::
Whenever a user clicks the button 'Add Comment' the the following code is called:
<br />
button_click(...)<br />
{<br />
            ...<br />
            IXmsComment cmt = new IXmsComment();<br />
            cmt.content = content;<br />
            cmt.date = DateTime.Now;<br />
            cmt.username = tbxUsername.Text;<br />
            AddComment(cmt);<br />
            if (divComments.Visible == false)<br />
                divComments.Visible = true;<br />
            updateComments.Update();<br />
}<br />
<br />
... AddComment(IXmsComment cmt)<br />
{<br />
            HtmlGenericControl divComment = new HtmlGenericControl("div");<br />
            //divComment.ID = "divAddedComment";<br />
            HtmlGenericControl divAuthor = new HtmlGenericControl("div");<br />
            HtmlGenericControl divDate = new HtmlGenericControl("div");<br />
            HtmlGenericControl divDescrip = new HtmlGenericControl("div");<br />
            //Assign CSS Classes to Controls:<br />
            divComment.Attributes.Add("class", "comment");<br />
            divAuthor.Attributes.Add("class", "commentAuthor");<br />
            divDate.Attributes.Add("class", "commentDate");<br />
            divDescrip.Attributes.Add("class", "commentDescription");<br />
            //Add Content to each Control:<br />
            divAuthor.InnerText = cmt.username; //text only<br />
            divDate.InnerText = cmt.date.ToString(); //text only<br />
            divDescrip.InnerHtml = cmt.content; //html allowed<br />
            //Add Controls to parent:<br />
            divComment.Controls.Add(divAuthor);<br />
            divComment.Controls.Add(divDate);<br />
            divComment.Controls.Add(divDescrip);<br />
            //add divComment to master div:<br />
            divComments.Controls.Add(divComment);<br />
            xms.Utils.scriptCalls.AnimateStatus(divComment.ClientID, updateComments);<br />
            UpdateProgress1.Visible = false;<br />
}<br />


Here is the update panel html:

<br />
<asp:UpdatePanel ID="updateComments" runat="server" UpdateMode="Conditional"><br />
    <Triggers><br />
        <asp:AsyncPostBackTrigger ControlID="btnSubmit" EventName="Click" /><br />
    </Triggers><br />
    <ContentTemplate><br />
        <div id="divComments" class="commentCollection" runat="server"></div><br />
        <div id="divNewComment" class="newComment" runat="server" visible="false"><br />
            <fieldset><br />
                <legend id="addCommentTitle" runat="server">Add Your Comment:</legend><br />
                <table><br />
                    <tr><br />
                        <td><br />
                            <asp:Label ID="lblUsername" AssociatedControlID="tbxUsername" runat="server" Text="Your Username: "></asp:Label></td><br />
                        <td><br />
                            <asp:TextBox ID="tbxUsername" Enabled="false" runat="server"></asp:TextBox></td><br />
                    </tr><br />
                    <tr><br />
                        <td><br />
                            <asp:Label ID="lblEmail" AssociatedControlID="tbxEmail" runat="server" Text="Your Email: "></asp:Label></td><br />
                        <td><br />
                            <asp:TextBox ID="tbxEmail" runat="server"></asp:TextBox><br />
                            <asp:RequiredFieldValidator ID="rfvEmail" runat="server" <br />
                                ControlToValidate="tbxEmail" ValidationGroup="CommentGroup"<br />
                                ErrorMessage="Email Address is required." Display="Dynamic" <br />
                                SetFocusOnError="True"></asp:RequiredFieldValidator><br />
                            <asp:RegularExpressionValidator ID="revEmail" runat="server"<br />
                                ControlToValidate="tbxEmail" ValidationGroup="CommentGroup" <br />
                                ErrorMessage="Invalid Email Address" Display="Dynamic" <br />
                                SetFocusOnError="True" <br />
                                ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator><br />
                            <asp:CustomValidator ID="cvEmail" runat="server" Display="Dynamic" ControlToValidate="tbxEmail" ValidationGroup="CommentGroup" <br />
                                ErrorMessage="Email Address provided does not match the email address in our records for your user account.  Please re-enter your email address." <br />
                                onservervalidate="cvEmail_ServerValidate" SetFocusOnError="True" ValidateEmptyText="true"></asp:CustomValidator><br />
                            <span class="req"></span></td><br />
                    </tr><br />
                    <tr><br />
                        <td><br />
                            <asp:Label ID="lblCaptcha" AssociatedControlID="imgCaptcha" runat="server" Text="Enter the text in the image:"></asp:Label></td><br />
                        <td><asp:Image ID="imgCaptcha" runat="server" /></td><br />
                    </tr><br />
                    <tr><br />
                        <td><br />
                            <asp:Label ID="lblCaptchaBox" AssociatedControlID="tbxCaptcha" runat="server" Text="Enter image text here:"></asp:Label></td><br />
                        <td><br />
                            <asp:TextBox ID="tbxCaptcha" runat="server"></asp:TextBox><br />
                            <asp:CustomValidator ID="cvCaptcha" runat="server" <br />
                                ControlToValidate="tbxCaptcha" ValidateEmptyText="true" ValidationGroup="CommentGroup"<br />
                                ErrorMessage="You must enter the text exactly as it appears in the image above." <br />
                                Display="Dynamic" onservervalidate="cvCaptcha_ServerValidate" <br />
                                SetFocusOnError="True"></asp:CustomValidator><br />
                            <asp:RequiredFieldValidator ID="rfCaptcha" ValidationGroup="CommentGroup" ControlToValidate="tbxCaptcha" SetFocusOnError="true" runat="server" ErrorMessage="Image verification is required."></asp:RequiredFieldValidator><br />
                            <span class="req"></span></td><br />
                    </tr><br />
                    <tr><br />
                        <td colspan="2" style="text-align:center;"><asp:Label ID="lblContent" AssociatedControlID="xmsRichEditor1" runat="server" Text="Your Comment:"></asp:Label></td><br />
                    </tr><br />
                    <tr><br />
                        <td colspan="2"><br />
                            <uc1:xmsRichEditor ID="xmsRichEditor1" runat="server" UseFullEditor="false" /><br />
                        </td><br />
                    </tr><br />
                    <tr><br />
                        <td>&nbsp;</td><br />
                        <td><br />
                            <asp:UpdateProgress ID="UpdateProgress1" AssociatedUpdatePanelID="updateComments" runat="server"><br />
                                <ProgressTemplate><br />
                                    <div style="width:100%; margin:0 auto;"><br />
                                        <img runat="server" id="imgLoader" src="~/App_Themes/default/images/ajax-mini-loader.gif" alt="loading... please wait." title="loading... please wait." /><br />
                                    </div><br />
                                </ProgressTemplate><br />
                            </asp:UpdateProgress> <br />
                            <asp:Button ID="btnSubmit" ValidationGroup="CommentGroup" CausesValidation="true" runat="server" Text="Add Comment" <br />
                                onclick="btnSubmit_Click" OnClientClick="Save();" /></td><br />
                    </tr><br />
                </table><br />
                <div id="divResult" class="status" runat="server" style="font-weight:bold;"></div><br />
            </fieldset><br />
        </div><br />
    </ContentTemplate><br />
</asp:UpdatePanel><br />


In the response from the server, I can see the new comment div added but the actual HTML of the page isn't updated, even though I've explicitly called updateComments.Update();.

The strange thing is if I do not do any AJAX/partial page postbacks before adding a comment via the button click, it works fine but after any AJAX/partial page postback (like adding a second comment without refreshing the page) I will see the new comment in the AJAX Response, but the HTML on the page isn't changed. Does anyone know why this is happening?
Thanks,
Shawn
GeneralCould this be a "typo"`? Pin
student_rhr9-Nov-09 12:49
student_rhr9-Nov-09 12:49 
GeneralRe: Could this be a "typo"`? [modified] Pin
Shawn Souto9-Nov-09 13:38
Shawn Souto9-Nov-09 13:38 
GeneralRe: Could this be a "typo"`? Pin
student_rhr10-Nov-09 5:37
student_rhr10-Nov-09 5:37 
GeneralRe: Could this be a "typo"`? Pin
Shawn Souto10-Nov-09 8:42
Shawn Souto10-Nov-09 8:42 
QuestionHow can I modify rows(xx) displayed in MultiLine Textbox datagridtemplate-itemtemplate dynamically Pin
rickqu9-Nov-09 4:58
rickqu9-Nov-09 4:58 
QuestionNotificate by sending an email automatically Pin
Member 47041439-Nov-09 3:56
Member 47041439-Nov-09 3:56 
AnswerRe: Notificate by sending an email automatically Pin
Gamzun9-Nov-09 4:03
Gamzun9-Nov-09 4:03 
AnswerRe: Notificate by sending an email automatically Pin
Parwej Ahamad9-Nov-09 4:03
professionalParwej Ahamad9-Nov-09 4:03 
GeneralRe: Notificate by sending an email automatically Pin
Member 47041439-Nov-09 4:32
Member 47041439-Nov-09 4:32 
GeneralRe: Notificate by sending an email automatically Pin
Parwej Ahamad9-Nov-09 4:51
professionalParwej Ahamad9-Nov-09 4:51 
GeneralRe: Notificate by sending an email automatically Pin
N a v a n e e t h9-Nov-09 5:36
N a v a n e e t h9-Nov-09 5:36 
AnswerRe: Notificate by sending an email automatically Pin
RyanEK9-Nov-09 13:49
RyanEK9-Nov-09 13:49 
QuestionHow to play the .vox file in browser. Using C# with Asp.net 2.0 Pin
bruze9-Nov-09 3:52
bruze9-Nov-09 3:52 
AnswerRe: How to play the .vox file in browser. Using C# with Asp.net 2.0 Pin
Richard MacCutchan9-Nov-09 3:56
mveRichard MacCutchan9-Nov-09 3:56 
GeneralRe: How to play the .vox file in browser. Using C# with Asp.net 2.0 Pin
bruze9-Nov-09 4:07
bruze9-Nov-09 4:07 
GeneralRe: How to play the .vox file in browser. Using C# with Asp.net 2.0 Pin
Richard MacCutchan9-Nov-09 4:16
mveRichard MacCutchan9-Nov-09 4:16 
GeneralRe: How to play the .vox file in browser. Using C# with Asp.net 2.0 Pin
bruze9-Nov-09 4:26
bruze9-Nov-09 4:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.