NOTE: Not specific to your problem, but shows an issue with application
setup.
If Page.IsPostBack Then
You should handle postback events in your control event handlers. Unless
every possible action you can ever add to a page does the same thing
(extremely rare), there is no need for the IsPostBack = true branch in the
Page_Load.
I would refactor this test into the button click event. If that is not
possible, then rethink the intent. If the textbox has to be visible to save
to the database, boom, there is your trouble. It is not visible until
someone does something on the page. ANd, if that is the intent, you need to
go through the process and add some validation when someone attempts to
submit via button without the box showing.

Signature
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA
*************************************************
| Think outside the box!
*************************************************
> Hello,
>
[quoted text clipped - 35 lines]
> myclass.save(ddl1,tb1)
> End Sub
Latish Sehgal - 18 Dec 2007 23:00 GMT
Why do you have AutoPostBack set to "True" in your textbox?
That causes the postback to happen everytime the text changes in your
textbox and it loses focus. So what's actually happening here is that
when you press the button, instead of the button handler being fired,
its the autopostback event from textbox.
And when you press the button again (if you do not change text), then
the button handler executes and saves your data.
Removing AutoPostBack=true from your textbox should fix this.
If however, you do want Autopostback to be true for your textbox, you
should create another textbox or some control there, so that when you
click on the new textbox, the autopostback event will fire then and
not block your button event handler.
-Latish Sehgal
http://www.dotnetsurfers.com/
Cowboy (Gregory A. Beamer) - 19 Dec 2007 16:11 GMT
I did not notice that in the OPs code, but that is a good point. It also
causes the If PostBack = True Then to fire every single time you update a
textbox, which kicks you into an interesting loop, albeit one that requires
user interaction. :-)

Signature
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA
*************************************************
| Think outside the box!
*************************************************
> Why do you have AutoPostBack set to "True" in your textbox?
> That causes the postback to happen everytime the text changes in your
[quoted text clipped - 12 lines]
> -Latish Sehgal
> http://www.dotnetsurfers.com/
Theo - 22 Dec 2007 14:46 GMT
Thanks
>I did not notice that in the OPs code, but that is a good point. It also
>causes the If PostBack = True Then to fire every single time you update a
[quoted text clipped - 19 lines]
>> -Latish Sehgal
>> http://www.dotnetsurfers.com/
gnewsgroup - 23 Dec 2007 05:43 GMT
On Dec 18, 12:18 pm, "Cowboy \(Gregory A. Beamer\)"
<NoSpamMgbwo...@comcast.netNoSpamM> wrote:
> NOTE: Not specific to your problem, but shows an issue with application
> setup.
[quoted text clipped - 59 lines]
> > myclass.save(ddl1,tb1)
> > End Sub
I have always been puzzled by the same kind of problem. It's been 1
year since I noticed that if I use the UpdatePanel of the MS ajax
framework, quite often a button has to be clicked twice to cause a
postback.
I have this problem with one page in my current web application. The
button itself is not inside an UpdatePanel, I do have a few controls
with AutoPostBack=true on the page.
I haven't figured out what is causing this problem. Any idea if this
indeed has to do with the ajax framework?