Solved

ASP.NET Post back problem

Posted on 2004-10-19
8
218 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ClickOnce Install - Shortcut Question 3 73
array11 challenge 16 61
control image tags in a string ? 12 111
Windows Service to Receive TCP Packets 4 124
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

895 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

14 Experts available now in Live!

Get 1:1 Help Now