Solved

ASP.NET Post back problem

Posted on 2004-10-19
8
222 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
8 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 100 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
Industry Leaders: 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!

 

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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
splitOdd10 challenge 5 125
Basic Java Case or If-Else statement... 3 64
SQL Insert parts by customer 12 51
asp Google Map 2 55
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this post we will learn different types of Android Layout and some basics of an Android App.
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…

685 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