Ask a Question related to ASP.NET General, Design and Development.
-
Ken Cox [Microsoft MVP] #1
Re: post to server using controls or code other than a button
Don't forget that the client-side script has a Submit() method that can submit
a form without a button.
In the following code, I use a literal control to output the Javascript the
first time. The Javascript inserts the time into the textbox and then submits
the form. When the page reloads, it displays the time as accepted by the
textbox and the time of the postback.
Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
If Not IsPostBack Then
Literal1.Text = "<script>document.forms[0].TextBox1.value=" & _
"'" & Now.TimeOfDay.ToString & "';document.forms[0].submit();</script>"
Else
Label2.Text = "I was posted back at: " & Now.TimeOfDay.ToString
Literal1.Text = ""
End If
Label1.Text = TextBox1.Text
End Sub
Does this help?
Ken
MVP [ASP.NET]
"Northern" <lifeng26@msn.com> wrote in message
news:055901c3515d$1ec2ff10$a001280a@phx.gbl...
If I have a button control that runat=server, then as soon
as user clicks on the button, server side event handler
get invoked. I want to have a effect that's similar to
that, but with other controls. Say, I have a text field.
What I want is, as soon as my front-end script put a
string into the text field the form get posted to the
server and the server side Text changed event get fired.
Right now, I don't seem to be able to do that. The text
change on the front-end doesn't trigger a server post. I
have to wait untill next time some button get pressed then
the server side detects the changed text and fires my text
change event handler. This doesn't work for me.
Can someone show me how to do this?
Thanks.
Ken Cox [Microsoft MVP] Guest
-
Controls that contain code: Code Blocks Not Supported
How can I develop a custom control that can then be used to display dynamically generated data? I have created a simple custom control which I use... -
composite controls... Microsoft Press: Dev ASP.NET Server Controls
I have the Microsoft Press: Developing Microsoft ASP.NET Server Controls and Components book. It's starting to shine some light on control... -
user controls: dynamiclly added child controls dont survive post back ?
hi, i have some strange behaviour: i've created a web user control that add's some child controls (e.g: textbox, image buttons) to its control... -
Disabling a button but calling its server code
Hi I am trying to create an "Update" button for my form. So far I have got it working fine, posting back and updating the record. Great! ... -
Subform Controls (please disregard previous post)
I have a subform with a variable amount of textboxes. Each textbox should have its own color, depending on the value of the field L3_Status. When... -
Ken Cox [Microsoft MVP] #2
Re: post to server using controls or code other than a button
BTW, is Northern your real name? If not, it is polite to sign with one.
"Northern" <lifeng26@msn.com> wrote in message
news:055901c3515d$1ec2ff10$a001280a@phx.gbl...
If I have a button control that runat=server, then as soon
as user clicks on the button, server side event handler
get invoked. I want to have a effect that's similar to
that, but with other controls. Say, I have a text field.
What I want is, as soon as my front-end script put a
string into the text field the form get posted to the
server and the server side Text changed event get fired.
Right now, I don't seem to be able to do that. The text
change on the front-end doesn't trigger a server post. I
have to wait untill next time some button get pressed then
the server side detects the changed text and fires my text
change event handler. This doesn't work for me.
Can someone show me how to do this?
Thanks.
Ken Cox [Microsoft MVP] Guest
-
John Kievlan #3
post to server using controls or code other than a button
Make sure you set AutoPostBack=true for the control in
question. That should fix the problem.
soon>-----Original Message-----
>If I have a button control that runat=server, then asthen>as user clicks on the button, server side event handler
>get invoked. I want to have a effect that's similar to
>that, but with other controls. Say, I have a text field.
>What I want is, as soon as my front-end script put a
>string into the text field the form get posted to the
>server and the server side Text changed event get fired.
>
>Right now, I don't seem to be able to do that. The text
>change on the front-end doesn't trigger a server post. I
>have to wait untill next time some button get pressedtext>the server side detects the changed text and fires my>change event handler. This doesn't work for me.
>
>Can someone show me how to do this?
>
>Thanks.
>.
>John Kievlan Guest



Reply With Quote

