Welcome Guest Search | Active Topics | Sign In | Register

Is EO.Web Suite has similar function like ScriptManager.RegisterClientScriptBlock? Options
Bruce
Posted: Monday, February 23, 2009 1:29:56 AM
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 ?
eo_support
Posted: Monday, February 23, 2009 7:26:15 AM
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!
Phil Morris
Posted: Tuesday, March 3, 2009 12:03:57 PM
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?)
eo_support
Posted: Tuesday, March 3, 2009 12:51:28 PM
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!
Saed
Posted: Thursday, March 5, 2009 7:08:26 PM
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
eo_support
Posted: Thursday, March 5, 2009 7:24:45 PM
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
Saed
Posted: Thursday, March 5, 2009 7:53:38 PM
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
eo_support
Posted: Thursday, March 5, 2009 8:03:01 PM
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
Phil Morris
Posted: Thursday, March 5, 2009 8:27:00 PM
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)
Saed
Posted: Friday, March 6, 2009 3:42:50 AM
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
Phil Morris
Posted: Friday, March 6, 2009 11:35:39 AM
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.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.