|
Rank: Member Groups: Member
Joined: 2/22/2009 Posts: 13
|
In AJAX ASP .NET Control Toolkit, I can call javascript function after Async Post Back. For example, after Button1_Click server-side event, I can add the following code to activate client-side function.
ScriptManager.RegisterClientScriptBlock(Me, GetType(Page), "javascript", "getObject('Textbox1');", True)
How can I do it the same thing by EO Web Suite ?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, The easiest way is to place a Label inside the CallbackPanel, then set that Label's Text to something like this:
Code: C#
Label1.Text = "<script type='text/javascript'>alert('hi!');</script>";
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 6/5/2007 Posts: 35
|
That's really useful, not just to pop up messages but also to pop up dialogs, force a client side redirect etc. How about expanding the callback panel to embed a label control that can be referenced as part of the callback panel properties. Such an embedded control could automatically wrap any passed text with the '<script> tags, eliminating the need for backend server code from having to do so?
Yes, I'm 'lazy' in that I'd much rather repetitive functions be done in one place (isn't that part of good s/w development?)
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Thanks for the suggestion. We will look into it and see if we can do that.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 10/15/2008 Posts: 45
|
I was thinking my grasp of EO.Web APIs (both Server & Client) is very humble. Now I see it is not me!
In my situation, I have multiple Dialogs which I need to control their show/hide from code-behind according to different conditions. Therefore, I used a TextBox. The problem is that TextBox MUST be visible if to handle its events, so I set its foreground and background as page background, turning it visually invisible!
The only events I found feasible were Focus() and Blur(), since other events (e.g. OnTextChange) don't fire if TextBox properties are set via code.
To show/hide a certain Dialog, I set Text of TB to a comma-delimited string comprising Dialog ID, its Hight & Width and its status (show or hide), after which I set TB's Focus() to True.
TB has it's AutoPostBack set to True. JS function is called via OnFocus(). The function reads TB Text and splits it forming Dialog properties, then acts accordingly. Just before calling eo_GetObject() to run the Dialog, I release TB focus via invoking Blur().
A lengthy workaround but turned very efficient in my situation; much more than ASP's ScriptManager or even altering Dialog's InitialState which for some reason didn't properly work for me.
Finally, I support Phil's valuable suggestion. It would be indeed a great add-on to have a companion control with Callback Panels that acts as a bridge between Server-Side code and EO Client API.
Hope this helps.
Regards,
Saed Hamdan "Man may be destroyed but not defeated" -Hemmingway
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
A new function RenderClientScript has already been added in our internal builds and it will be available in our next public build. It is not exactly the same, but very similar to ScriptManager.RegisterClientScriptBlock.
I am not sure if I got your textbox solution correctly, specifically I do not know why it is necessary to rely on Focus and Blur to trigger JavaScript code for you. Also Dialog's InitialState should work.
Thanks for sharing anyway!
Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 10/15/2008 Posts: 45
|
eo_support wrote:A new function RenderClientScript has already been added in our internal builds and it will be available in our next public build. It is not exactly the same, but very similar to ScriptManager.RegisterClientScriptBlock.
Great. Would it directly execute set ClientScript? eo_support wrote:I am not sure if I got your textbox solution correctly, specifically I do not know why it is necessary to rely on Focus and Blur to trigger JavaScript code for you. Also Dialog's InitialState should work.
Can't see why, but Dialog's InitialState sometimes work and sometimes doesn't?! As for TB, I was looking for a TB event that auto-fires when its text is changed, thus, runs JavaScript code. As I said, tried different possible events without much luck. Events like OnKeyUp and OnTextChange will only fire if user manually enters TB text then moves out of TB. Changing TB text via code doesn't trigger either events. Using a Delegate to mimic OnTextCahange didn't work either. Therefore, the only alternative was to manipulate TB's Focus() and Blur(). Hope this clarifies. Or may be I'm missing something here. Regards, Saed Hamdan"Man may be destroyed but not defeated" -Hemmingway
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
RenderClientScript allows you to execute whatever javascript you provided after the CallbackPanel updates.
Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 6/5/2007 Posts: 35
|
Saed - do a Google search for javascript capture keystrokes for numerous examples of how to capture keystokes on the client side. For example http://www.maconstateit.net/tutorials/JSDHTML/JSDHTML15/jsdhtml15-05.htm (I bookmarked that for future reference)
|
|
Rank: Advanced Member Groups: Member
Joined: 10/15/2008 Posts: 45
|
Thanks for the link Phil, but sounds you missed my point...
In order to capture keystrokes, user MUST physically place cursor inside textbox (by mouse or by Tab), key in data then moves the mouse out of the textbox or press tab again. Only then keystroke capturing events will fire. If you try to change textbox content by code, e.g. myTB.Text = "whatever", said events will NOT fire.
Hope you get it now.
Regards,
Saed Hamdan "Man may be destroyed but not defeated" -Hemmingway
|
|
Rank: Advanced Member Groups: Member
Joined: 6/5/2007 Posts: 35
|
Saed, sorry but I don't get it. The link I quoted above illustrates the use of Javascript to prevent entry of non-numeric data into a textbox. The user only has to type the character for the javascript event to fire.
And although this may be a discussion of some interest, it has nothing to do with EO tools, so perhaps needs to be carried on in a more appropriate forum, not this site.
|
|