What causes a server event to fire due to a change on the client?

J

John Dalberg

What causes a server event to fire when something happens on the client?
Say a user changed the gridview's page index, the server side
PageIndexChanged event is fires.

What makes PageIndexChanged fires? Is it a field in the viewstate? Is it a
value in the forms collections? I am trying to understand the mechanism of
communication between the browser and the server.

John Dalberg
 
B

bruce barker

the communication betweoen the client and server are html form fields
(input,select, and textarea). when a postback happens the form fields
are sent to the server as name/value pairs.

when you write a server control your control responds to two events (not
real events they are interface methods rather than delegates) generated
by the frame work.

1) LoadPostData - your control called and passed all the form postback
values, and your data key (rendered control name).

you can store you original value in viewstate, and compare the postback
value to it. if different you can raise some sort of OnChange event

2) RaisePostBackEvent - you control will render some client script to
raise this event by calling __dopostback with the control name and one
option string arg. the name and arg are stored in hidden fields and form
postback is done.

server side the framework will see this control name in the postback
data, and call this RaisePostBackEvent. your control then raises
whatever event(s) (say onclick) it wants.

see its all very simple.


-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top