Forum


HomeHomePremiumPremiumDevelopmentDevelopmentAJAX Update - Keypress ProblemAJAX Update - Keypress Problem
Previous
 
Next
New Post
10/17/2013 9:56 AM
 

I am trying to add content that gets updated with AJAX to my module and am having some problems. I have the basic functionality working but am getting undesired behavior  when the enter key is pressed.  Here is what I am trying to do and what I am experiencing.

The behavior I want is to have the page function just like it does when I press the button when the user presses the enter key.

The behavior I am seeing is that when I press enter, I am redirected to the home page of the site, the update function is not called.

I think this is because DNN wraps the module with it's own HTML that contains a form.  I think this wrapping form is submitted instead of it causing my UpdatePanel content to be updated.

Here is the code for my AJAX Update Panel with some things stripped for simplicity:

<asp:UpdatePanel ID="myPanel" runat="server">
    <ContentTemplate>
        <asp:Repeater ID="myRepeater" runat="server">
            <HeaderTemplate>
                <div>
            </HeaderTemplate>
            <FooterTemplate>
                </div>
            </FooterTemplate>
            <ItemTemplate>
                <asp:TextBox ID="myTxt" Columns="3" runat="server" Text="" />
            </ItemTemplate>
        </asp:Repeater>
        <asp:Button runat="server" ID="myUpdateButton" OnClick="myUpdateButton_Click" Text="Update" />
    </ContentTemplate>
</asp:UpdatePanel>

I was seeing similar behavior with a non-AJAX form.  I wrapped the non-ajax form with an <asp:Panel id="myPanel" runat="server" DefaultButton="myUpdateButton"> tag.  This worked well but I am not sure how get the same behaviour using the <asp:UpdatePanel>.  How do I make this happen?

Thanks

-"Look to the sky as much as the screen!"

 
New Post
10/17/2013 5:06 PM
 

It is somewhat humorous that the complete answer is contained within the original question.

To overcome this problem, I simply put a <asp:Panel> with a default button inside of my <asp:UpdatePanel>.  The code looks something like this:

<asp:UpdatePanel ID="myPanel" runat="server">
    <ContentTemplate>
        <asp:Panel ID="pnlInner" runat="server" DefaultButton="myUpdateButton">
            <asp:Repeater ID="myRepeater" runat="server">
                <HeaderTemplate>
                    <div>
                </HeaderTemplate>
                <FooterTemplate>
                    </div>
                </FooterTemplate>
                <ItemTemplate>
                    <asp:TextBox ID="myTxt" Columns="3" runat="server" Text="" />
                </ItemTemplate>
            </asp:Repeater>
            <asp:Button runat="server" ID="myUpdateButton" OnClick="myUpdateButton_Click" Text="Update" />
        </asp:Panel>
    </ContentTemplate>

</asp:UpdatePanel>

 Hope this helps if anyone has this issue.

 

"Look to the sky as much as the screen!"

 
Previous
 
Next
HomeHomePremiumPremiumDevelopmentDevelopmentAJAX Update - Keypress ProblemAJAX Update - Keypress Problem



Try FREE
30 days money back guaranteed