473,327 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

IsPostBack problem...

12
I have a pop up calendar. On the selection of date from calendar it should be displayed in the text box.

The problems are:
1)Initially when the page loads the text box shows some date, its not empty.
2)When i click on a date it shows the previously clicked date.

I have set the AutoPostBack property of textbox control to false.
The code behind page is :
Expand|Select|Wrap|Line Numbers
  1. protected void StartDateCalendar_Load(object sender, EventArgs e) 
  2.  
  3. TextBox1.Text = StartDateCalendar.SelectedDate; 
  4. if (Page.IsPostBack) return; 
  5. this.TextBox1.Text = DateTime.Now.ToShortDateString(); 
  6. this.StartDateCalendar.SelectedDate = this.TextBox1.Text; 
  7.  
Please help..
Thanks in advance,
Saira.
Sep 27 '07 #1
7 1443
Hi,

please try this in page_load event
Expand|Select|Wrap|Line Numbers
  1. if (!Page.IsPostBack)
  2. }
  3. this.TextBox1.Text = DateTime.Now.ToShortDateString(); 
  4. this.StartDateCalendar.SelectedDate = this.TextBox1.Text; 
  5.  
regards




I have a pop up calendar. On the selection of date from calendar it should be displayed in the text box.

The problems are:
1)Initially when the page loads the text box shows some date, its not empty.
2)When i click on a date it shows the previously clicked date.

I have set the AutoPostBack property of textbox control to false.
The code behind page is : [code=cpp]
protected void StartDateCalendar_Load(object sender, EventArgs e)
{

TextBox1.Text = StartDateCalendar.SelectedDate;
if (Page.IsPostBack) return;
this.TextBox1.Text = DateTime.Now.ToShortDateString();
this.StartDateCalendar.SelectedDate = this.TextBox1.Text;

} [code]
Please help..
Thanks in advance,
Saira.
Sep 27 '07 #2
bsaira
12
Hi,

please try this in page_load event

if (!Page.IsPostBack)
}
this.TextBox1.Text = DateTime.Now.ToShortDateString();
this.StartDateCalendar.SelectedDate = this.TextBox1.Text;
}

regards


I did this before but the problem still persists...
Its showing me the previously clicked date..
Please help...
Sep 27 '07 #3
Shashi Sadasivan
1,435 Expert 1GB
What you are doing is something which an event handler should be handling
when a postback event occour from the chage on date in you calendar, in your case
only the first line of the page load occours
at this time, page loads has the current state of the page (ie you have selected a new date, but that has not been registered yet)

pull that first line of code into the calendar's Selectionchanged event handler and you will be happy with what you see.

cheers
Sep 27 '07 #4
mzmishra
390 Expert 256MB
Expand|Select|Wrap|Line Numbers
  1. private void Calendar1_SelectionChanged(object sender, EventArgs e)
  2.         {
  3.  
  4.             TextBox.Value = Calendar1.SelectedDate.Date.ToString();
  5.  
  6.         }
Sep 27 '07 #5
Frinavale
9,735 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. private void Calendar1_SelectionChanged(object sender, EventArgs e)
  2.         {
  3.  
  4.             TextBox.Value = Calendar1.SelectedDate.Date.ToString();
  5.  
  6.         }
Try using:
TextBox.Text=Calendar1.SelectedDate.ToString("MM/dd/yyyy")

Could you also post your Page_Load function.

(Please post your code within [code] tags....
For instance if you want to post C# code please type the following:

[cpp=cpp]
/*My C# Code*/
[/code]


This just makes it easier to read...)

Thanks,

-Frinny
Sep 27 '07 #6
could you disable viewstate, which always keep old data if it is ture.
Sep 27 '07 #7
bsaira
12
Thanks to all the people out there for helping me...

The issue got resolved. I didn't register the textboxes so when i added the below code into my Page_Load method ..it worked..

// My C# Code

if (Page.IsPostBack) return;
this.StartDateCalendar.RegisterControl(ref TextBox1);
this.EndDateCalendar.RegisterControl(ref TextBox2);
this.Page.LoadComplete += new EventHandler(Page_Load);

Thanks once again.........
Sep 28 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Tim | last post by:
To make !Page.IsPostBack to work, do I need to set any properties at page level or in the config files(Web, machine) or aspx files. Because code in under the !IsPostBack is executing twice and...
3
by: Mathana g | last post by:
Hi, I have snippet as follows if(!IsPostBack) LoadPreRequisites(); I am getting IsPostBack as true even the page loads first time. What might be the problem
2
by: patrick_a | last post by:
Hi, I'm having trouble with using !IsPostBack. I want to create a linkbutton within a table when the page loads the first time and then have the page redirect based on the...
0
by: Boris Zakharin | last post by:
I am using the .Net framework 1.1 and VS.NET 2003. I have some code where, for some reason, IsPostBack returns false messing up my code. I have a DataGrid, whose data I am trying to edit. Instead...
4
by: TJ | last post by:
Hi, There is one aspx web page that contains usercontrol. In aspx page and usercontrol , there is each submit button... Here is what I want... I want to process something depending on each...
6
by: RA | last post by:
btnAdd_Click does not get hit; if I have IsPostBack check in Page_load. If I don't have IsPostBack check; I am able to debug through btnAdd_Click. If I don't look for IsPostBack then it...
5
by: David Lozzi | last post by:
Hello, I have an interesting issue, so bear with me as I try to explain. I have a datalist posing as tabs for my application. And as each tab is clicked, a placeholder is then populated with the...
4
by: gihope | last post by:
Hi, I have an ASP.NET 2.0 C# issue that has been troubling me for some time, and if someone could shed some light on this I would appreciate it. This seems to be a commonly themed question,...
0
by: DC | last post by:
Hi, I am dynamically adding a usercontrol that uses "this.IsPostBack" in Page_Load to decide whether it must populate some of it's inner controls or not. Since I am adding the usercontrol to the...
5
by: BM | last post by:
I have a question that seems like it should have a simple answer, but I can't seem to find it by searching... Anyway, I'm trying to capture the IsPostBack event when I select an item within an...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.