Solved

ASP.NET Post back problem

Posted on 2004-10-19
8
216 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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 …

746 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

12 Experts available now in Live!

Get 1:1 Help Now