Solved

ASP.NET Post back problem

Posted on 2004-10-19
8
224 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: 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

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

A short article about a problem I had getting the GPS LocationListener working.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
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…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

737 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