?
Solved

ASP.NET Post back problem

Posted on 2004-10-19
8
Medium Priority
?
238 Views
Last Modified: 2010-04-17
i am using ASP.NET, C# and SQL SERVER2000

i have a page with one Textbox and a Button,
my question is i want to avoid the page load event when i click on the button , (i mean click event)
because i found that page load event is firing first before the button click event.

For me what i wanted to do is when i Click on the button i want to update somevalues to the database. For Ex.
i have two function
1. DisplayValue() // is for fetch the value from databse and display it to the Textbox.
2.UpdateValue() // is for fetch the value from Textboxe and insert/update into Database.

for Ex. my code look slike this
private void Page_Load(object sender, System.EventArgs e)
{
     DisplayValue()  // I must use this function because i want to display the value when page loads.

}
private void btnUpdate_Click(object sender, System.EventArgs e)
{
     UpdateValue()
// it should take the present value in the Textbox and Update ( unfortunatly present value  is               changing with the datbase value cos of Page_load :-(

}

Here in my case i am changing the value in the Textbox and click the Update button, for update the value to the Database. BUT when i click Update button , the Page_Load fires and set the textbox value from the databse so it will get changed the value i Enterd in the page...! then only btnUpdate_Click event fires, so always it will get updat the exsiting value not the value i am entering in the Textbox..!

IF I DON'T USE the DisplayValue()  function in the Page_Load , then it is UPDATING properly..!  but then how do i DISPLY the present value in Database?

PLS HELP....
Thanks
CoSree


0
Comment
Question by:CoSreejith
  • 3
  • 3
6 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 300 total points
ID: 12345979
private void Page_Load(object sender, System.EventArgs e)
{
    if (!IsPostBack)
        ...
}

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebUIPageClassIsPostBackTopic.asp
0
 

Author Comment

by:CoSreejith
ID: 12346092
ThankX Alex ..  i am begginer in .Net, thankX forur help it was this much easy :-) if i knew that i may not give 100 point :-(
anyway thankx
CoSree(sreehere@gmail.com)
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 12346266
Setting C grade you don't save your points or money.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:CoSreejith
ID: 12346416
i duno that, i just selected somethgin like that only.. if it is possible i will change it to high grade
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 12346440
I will ask Community Support to change the grade, I hope you agree.
0
 

Author Comment

by:CoSreejith
ID: 12346464
okay Done ! are u online right now? in yahoo or msn if so <Email Removed by CS. See http:help.jsp#hi99> guess i can have ur help in future, i am from India workign with Norway company
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

850 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