Solved

Add record to a database without postback

Posted on 2009-06-27
5
596 Views
Last Modified: 2013-12-17
Hi,

I need a good idea how to do something like this:
I've to add new entries to a database using a web interface.
The "Add" button is outside the input fields in a footer of the page so I can't do anything in one updatepanel (customer like to have so).
So it would look like this:

Header
-----------------------------------
M | Input1
E | Input2
N | Input3
U | Input4
-----------------------------------
Add

I like to only let the main part of the side refresh after a "Add" and start again with empt fields.
My only idea how to do is to parse the input fields with javascript, submit the data and send a refresh to a updatepanel container of the input fields.

Is there any easier way how to do?

Thanks,

Andre
0
Comment
Question by:andre72
5 Comments
 
LVL 15

Expert Comment

by:jinal
ID: 24727571
Hello ,

You can do that by using pure AJAX.

Try that.

0
 

Author Comment

by:andre72
ID: 24727720
Do you have a how to for me please?
0
 
LVL 18

Accepted Solution

by:
carlnorrbom earned 500 total points
ID: 24917067
Hi,

If you need to keep the add button outside the update panel you can add it as async postback trigger such as:

    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            Your input markup goes here.
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnAdd" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>
    <asp:Button ID="btnAdd" runat="server" Text="Add" />

This way the update panel will refresh even though the add button is placed outside the update panel.

/Carl.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

747 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

10 Experts available now in Live!

Get 1:1 Help Now