Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Handling a Click Event
Message
From
22/11/2003 16:11:23
Keith Payne
Technical Marketing Solutions
Florida, United States
 
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00852578
Message ID:
00852676
Views:
6
>>James,
>>
>>You can't call a server side function from client-side javascript, and you can't call a client-side javascript function from the server. The reason is that all of the server side execution happens _before_ the HTML is sent to the browser.
>>
>>If you assign the OnClick attribute of an HTML or asp element, the server-side click event is not raised.
>>
>>What you can do is add your script code to the Response stream during the postback so that it is executed when the HTML is sent to the browser. You can do this with Response.Write or Page.RegisterClientStartupScript.
>
>OK Its kinda what i thought for the state of things. So this line works fine.
>e.Item.Attributes.Add("ondblclick", "Javascript:__doPostBack('myDblClick','" & e.Item.ItemIndex & "');")
>
>two more newbie questions.
>Is the "__EVENTARGUMENT" only a string or can it be the aurgument object?
>e.Item.Attributes.Add("ondblclick", "Javascript:__doPostBack( e );")
>
>I am not familiar with "Page.RegisterClientStartupScript" where can I find info on this?
>
>thanks in advance.

Oops! Page.RegisterClientStartupScript is incorrect. It should be Page.RegisterStartupScript. You can get info on it in the VS.NET help files at ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfSystemWebUIPageClassRegisterStartupScriptTopic.htm or type under "RegisterStartupScript method" in the index.

To answer your first question, your browser doesn't know what 'e' is and the script is executing inside your browser. So you can't use 'e' as a parameter in a script block. __EVENTARGUMENT has to be a string.
Previous
Reply
Map
View

Click here to load this message in the networking platform