Welcome Guest Search | Active Topics | Sign In | Register

Newbie: Is there a one-step solution? Options
FredD
Posted: Sunday, November 18, 2007 2:45:28 PM
Rank: Newbie
Groups: Member

Joined: 11/18/2007
Posts: 2
HI,

Two issues:

1. I'm looking for a one-stop solution to AJAXing our VS2003 app. I don't want any of the controls you offer (at this point), just a panel that I can place on the .ASPX page that will wrap around all the controls on the page and automatically convert everything to from postback to AJAX callback.

A typical web page has 80 to 90 controls (buttons, dropdowns, labels, grids, panels etc. etc.) spread over several panels, some of which are hidden at any time. Also, a page has substantial javascript on it, including Web Service calls.

How would I use EO to handle my AJAX needs? Like I said, I don't want to change all the controls.

2. I have tried a few solutions, but they all fail on situations like the following where there is code like this:

Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click

s = "sub1/searchpage.aspx?user=" & strSessionID & "&id=9999"

Response.Write("<script>var winHeight=575;var winWidth=795;var winLeft=20" & _
";var winTop=20;var win=null;win=window.open('" & s & "'," & _
"'animation','width='+winWidth+',height='+winHeight+', left='+winLeft+', " & _
"top='+winTop+', directories=no, toolbar=no, resizable=yes, menubar=no, scrollbars=no, " & _
"location=yes, status=yes');win.focus();</script>")

In all the tests I've done, none would pop up this window.

Can you give me some advice, please on how to use EO for situations like this?

Thanks,
Fred
eo_support
Posted: Sunday, November 18, 2007 3:17:00 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi Fred,

You can use our CallbackPanel. You generally do not need to change any of your existing code to use our CallbackPanel. In order to use CallbackPanel, you need to:

1. Put a CallbackPanel around the region you want to AJAX update;
2. Set the CallbackPanel's Trigger property to include the control that you would like to trigger the Callback.

For example, let say you have a simple Button and Label in the page, and when user click the button, the page posts back and update the label to display the current time:

Code: HTML/ASPX
<asp:Button runat="server" id="Button1" Text="Test">
<asp:Label runat="server" id="Label1">


Code behind:

Code: C#
private void Button1_Click(object sender, EventArgs e)
{
    Label1.Text = DateTime.Now.ToString();
}


If you want to AJAX update the label, you can change your ASPX to:
Code: HTML/ASPX
<asp:Button runat="server" id="Button1" Text="Test">
<eo:CallbackPanel runat="server" id="CallbackPanel1"
    Triggers="{ControlID:Button1;Parameter:}">
    <asp:Label runat="server" id="Label1">
</eo:CallbackPanel>


Note you have put a CallbackPanel around Label1 and also have "Button1" included in its Triggers collection. You do not need to change any code behind. In reality you would usually put more than one controls inside the CallbackPanel. The CallbackPanel defines the boundary of the AJAX-updated region.

This does not solve your second scenario. For the second sceanrio, you will need to change your code. In short, you can not use Response.Write when AJAX updating your page (this is why none of the solution you have tried worked). Fortunately, there is an easy workaround that is possible with our CallbackPanel. As a general rule, you can replace any Response.Write with a Label control. For example, if your original code is:

Response.Write(
"<script type=\"text/javascript\">window.alert('hi');</script>");

You can put an asp:Label in your ASPX file, then replace Response.Write with:

Label1.Text =
"<script type=\"text/javascript\">window.alert('hi');</script>";

Obviously, the Label control has to be placed at the where you want that code to be. Once you replace your Response.Write with Label control and the corresponding code that sets the Label's Text, you should be all set. Make sure you have type="text/javascript" with your script tag.

For more detailed information, you can refer to our help file. You can also load and run our demo project to see how it works. Both are installed locally on your machine if you install our controls. Sample project are provided in Visual Studio 2003, 2005 and 2008 project format.

Thanks
FredD
Posted: Sunday, November 18, 2007 4:34:37 PM
Rank: Newbie
Groups: Member

Joined: 11/18/2007
Posts: 2
Thanks for the excellent reply. Re: the second issue: I'm afraid I don't understand. Typically, the script is assembled in Code Behind in a sub then issued in the Response.Write. The end result is that the original page remains open and visible to the user and a "pop-up" page also displays.

You are suggesting putting that code in a label. How does that trigger the pop-up? I'm not clear on that.

Also, we've had some issues with web service calls where the DIV that uses the service is initialized in the OnPageLoad event of the form, but, because AJAX doesn't trigger the OnPageLoad event thereafter, the DIV is no longer recognized and therefore isn't available for web service calls. Have you had this issue come up?

FredD
eo_support
Posted: Sunday, November 18, 2007 4:56:57 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi Fred,

The easiest way for you to understand Response.Write and Label.Text is to try it. Just create a blank page, put a Label on it, then do this in Page_Load:

Label1.Text =
"<script type=\"text/javascript\">window.alert('hi');</script>";

You may need to translate the C# syntax to VB syntax. Run the page and you will see how it works.

Theoratically you should be able to replace all Response.Write with Label if you know where the output should appear --- which should never be a problem.

Our AJAX solution shouldn't have any impact on OnPageLoad event or whatever other events. The biggest advantage of our CallbackPanel is that it works transparently -- you do not need change your server side code, they continue to work exactly the same as without our CallbackPanel. That means our CallbackPanel does not alter your server side code flow.

Thanks


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.