Add your own alternative version
Stats
643K views 6.4K downloads 195 bookmarked
Posted
15 Mar 2004
Licenced
|
Comments and Discussions
|
|
Please clarify license :-
RemoteScripting.cs : "This file and the accompanying source code may not be hosted on a website or bulletin board without the author written permission."
rs.js : no license mentioned.
|
|
|
|
|
Hi:
I am trying to figure out which license applies to CXEdit. Can you please help me with this?
Thanks,
Gwyn
|
|
|
|
|
<script type="text/jscript" language="javascript" src="rs.js"></script>
<script type="text/jscript" language="javascript">
var interval = "";
function OnPageLoad() {
interval = window.setInterval("Update()", 50000);
}
function Update() {
RS.Execute("Chat.aspx", "redraw");
RS.PopupDebugInfo();
}
</script>
public void redraw()
{
int[] exp = new int[l.Count];
List<Message> updList = new List<Message>();
ChatBox.Text += "r";
for (int i = 0; i < l.Count; i++)
{
Message m = l[i];
if (!m.isExpired())
{
updList.Add(m);
}
ChatBox.Text = m.getMsg() + "\n" + ChatBox.Text;
}
l = updList;
onlineBox.Text = "Online";
foreach(String s in users)
{
onlineBox.Text += "\n" + s;
}
}
Won't work. The method returns "Busy" on debug popup. Any help?
|
|
|
|
|
Hi, on all of my systems (vista, xz, 2k3 either in english or in italian) this character [’] (without the brackets) causes an error.
I'm using the code changes suggested here
http://www.codeproject.com/KB/aspnet/AlvaroRemoteScripting.aspx?msg=1343968[^] but no luck.
The error is:
System.FormatException occurred
Message="Could not find any recognizable digits."
Source="mscorlib"
StackTrace:
at System.ParseNumbers.StringToInt(String s, Int32 radix, Int32 flags, Int32* currPos)
at System.Convert.ToInt16(String value, Int32 fromBase)
at AMS.Web.RemoteScriptingClient.JS.DecodeUrl(String url) in D:\Progetti\PMC\INVCIW\v.1.0.0\branches\1.10.0.0b\src\RemoteScripting.cs:line 416
Any help would be greatly appreciated.
Regards,
Massimiliano
|
|
|
|
|
Hi, All,
I have seperated the reDemo.aspx to two files.
in reDemo.aspx:
RS.Execute("reDemoServer.aspx","UpdateAmounts", .............."
Inside reDemoServer.aspx file, declare the function UpdateAmounts(), I change the server side code from C# to VB.Net, everything works fine.
But if I include a file that create DB connection, when I return the connection string, it's empty.
Can anybody tell me what's wrong.
The codes in reDemoServer.aspx are as the following:
<![CDATA[<%@ Page Language="VB" %>]]>
<!-- #INCLUDE FILE="../../include/dbConnection.aspx" -->
Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If AMS.Web.RemoteScripting.InvokeMethod(Page) Then
Return
End If
End Sub
Public Function UpdateAmounts(ByVal argu1 as string) As String
Return "Return String From Remote Scripting." 'Works fine
'Return myConn 'myConn is defined in above include file, it's a
'string , but when I return it, it's an empty.
End Function
I need to solve this soon, otherwise I cannot do the furthere work.
Please help, thanks!
Andraw
|
|
|
|
|
I use VB instead of C#.
Nothing wrong, but callBack() function is not trigered.
In client-side in file1.aspx:
<script language='JavaScript' src='/script/rs.js'></script>
<script language='JavaScript' >
function xxxx(){
RS.Execute("anotherFile.aspx", "CreateHolder1", callBack);
}
function callBack(result){
alert(result);
}
<script>
'''''''''''''''''''''
In server-side in anotherFile.aspx:
<@ Page Language="VB" >
<%if AMS.Web.RemoteScripting.InvokeMethod(Page) then
response.end
end if
Function CreateHolder1() As String
CreateHolder1= "OK"
exit Function
%>
Can anybody tell me what's wrong?
Thanks!
Andraw
|
|
|
|
|
Sorry mistyping, exit Function should be end function. but still doesn't work.
|
|
|
|
|
Hi,
I have question, I seperate the rsDemo.aspx to two files, put the remote call function to another file(called rsDemoServe.aspx), inside this file:rsDemoServe.aspx are:
<!-- Remote Scripting Demo -->
void Page_Load(object sender, EventArgs e)
{
if (AMS.Web.RemoteScripting.InvokeMethod(Page))
return;
}
public string UpdateAmounts(string type)
{
return "OK|Hello|Lucy"; //result.ToString();
}
But when I modify the code as VB formate, it don't work. Do I must use C#?
Andraw
|
|
|
|
|
Hi Alvaro,
I'm using your code in an ASP.net 2.0 application and it is really useful.
Recently I have following problem:
When I'm calling a server-side method from my javascript and pass a string as parameter which contains an "umlaut" like the word "eisbär", during the transfer it transforms to "eisbr". In the server-side method which is called only the wrong parameter arrives.
Is there a possibility to change the charset or text encoding (I'm not sure) so that I can use UTF-8 characters?
I would be thankful for any information or ideas.
Veronika
|
|
|
|
|
|
I have problem getting this to work with .Net 2.0. Does anyone has this work w/ 2.0?
Error msg:
---------------------------
Microsoft Internet Explorer
---------------------------
System.MissingMethodException: Method 'ASP.default_aspx.Method1' not found.
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
at AMS.Web.RemoteScriptingClient.InvokeMethod() in RemoteScripting.cs:line 265
---------------------------
OK
---------------------------
To repro, here is the code:
Code:
My aspx page:
--------------------------------------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title>Untitled Page
function Method1CallBack(results)
{
alert('Method1CallBack returned results: ' + results);
}
function ExecMethod1()
{
alert('in ExecMethod1');
RS.Execute('Default.aspx', 'Method1',
'value1', 'Method1CallBack');
}
<asp:Button ID="SubmitButton" runat="server" OnClientClick="ExecMethod1(); return false;" Text="Submit" />
--------------------------------------------------
My aspx.cs code:
--------------------------------------------------
using System;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (AMS.Web.RemoteScripting.InvokeMethod(Page))
return;
}
public string Method1(string value)
{
return "true,";
}
}
--------------------------------------------------
-TL
-- modified at 18:32 Wednesday 13th June, 2007
|
|
|
|
|
Hi Timothy,
On first sight I would say don't use quotes in this place:
instead of
RS.Execute('Default.aspx', 'Method1', 'value1', 'Method1CallBack');
use
RS.Execute('Default.aspx', 'Method1', value1, Method1CallBack);
Only an idea, thats the way I use it.
Veronika
|
|
|
|
|
Thanks Veronika, that was it. I put the call back function in quote. The correct call should be:
RS.Execute('Default.aspx', 'Method1', 'value1', Method1CallBack);
This still works beautifully in VS 2005.
-TL
|
|
|
|
|
Hi, i download your example app in C# , and i add new lines :
i am created a checkbox type ASP ------> <asp:CheckBox ID="CheckBox1" runat="server" Checked="false" /> , your status cehcked is false
And in the method public string UpdateAmounts(string type) , i add a new line -
----->CheckBox1.Checked = true;
but when executed this program, the checkbox don't changed??? please tell me , what do wrong?
thansk for you answer
|
|
|
|
|
Hi Alvaro.
You look like the one who gave the direction to Microsoft on how to make Callback in their 2005 .NET version.
I am a beginner programmer, and I want to know if I can use your code for one of my projects at work.
Thanks,
Sookhee
|
|
|
|
|
MyDays wrote: I am a beginner programmer, and I want to know if I can use your code for one of my projects at work.
Of course, help yourself.
Regards,
Alvaro
Eat right. Exercise. Die anyway.
|
|
|
|
|
I recently (today) came across this article and thought that is exactly what I need to do as part of my Msc project.
So I downloaded you code, it worked fine.
I then created my own page, like yours, but I dont want a callback to the client, I simply want to call a server side method, and thats it. Which seems to be ok, with what you have implemented, as you state that the callback is optional.
OK, so what I need to do is, call the method from the client, then in the method at server side, I want to change some properties of another (more in the real project) of another server side web control, you know with the runat="server" attribute. The samll page I am trying it on has a TextBox, and I am trying to change the Text property in the remote method call, Like shown below
THE MARKUP: Tets.aspx
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%@ Page language="c#" Codebehind="Tets.aspx.cs" AutoEventWireup="false"
Inherits="ASP_pics.Tets" %><br>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ><br>
<HTML><br>
<HEAD><br>
<title>Tets</title><br>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET
7.1"><br>
<meta name="CODE_LANGUAGE" Content="C#"><br>
<meta name="vs_defaultClientScript" content="JavaScript"><br>
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"><br>
<script language='javascript' src='scripts/rs.js'></script><br>
<script language='javascript'><br>
function testServerScript()<br>
{ <br>
window.status = "A Small maybe niave test...";<br>
RS.Execute("Tets.aspx", "PopulateText", "some text for
TextBox1");<br>
alert("testServerScript was called");<br>
}<br>
</script>
<p> </HEAD><br>
<body MS_POSITIONING="GridLayout" onload="testServerScript();"><br>
<form id="Form1" method="post" runat="server"><br>
<asp:Button id="Button1" Runat="server" Text="Button"></asp:Button><br>
<asp:TextBox id="TextBox1" runat="server" Width="216px"></asp:TextBox><br>
</form><br>
</body><br>
</HTML><br>
</p>
</body>
</html>
THE CODE BEHIND: Tets.aspx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace ASP_pics
{
public class Tets : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
if (AMS.Web.RemoteScripting.InvokeMethod(Page))
return;
}
public void PopulateText(string txt)
{
TextBox1.Text= txt;
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
So thats what I am tring to do, but am totally not getting, if what you have done, even allows for this. It should, shouldnt it, or have I got it completely wrong.
I am new to the whole Ajax style of thing, I get the concept, I know this is not Ajax, but to me it is exactly what I wanted, An Ajax type of arrangement, where I could call a server method, without a callback, this is what I want to do.
PLEASE PLEASE PLEASE could you have a look at this simply example I am doing, and see what I am doing wrong.
I would be happy to email source if you like, my email, is sachabarber@hotmail.com
MANY THANKS
sacha barber
|
|
|
|
|
If you haven't already, I recommend you use an Ajax implementation, like Anthem.NET which will do what you want. However, to answer your particular question, you really didn't need Remote Scripting to change a textbox on the form. You could have done it with some simple Javascript on the client:
document.getElementById("TextBox1").value = "some text for TextBox1";
Regards,
Alvaro
Eat right. Exercise. Die anyway.
|
|
|
|
|
Yeah its has been working with Ajax library for .NET for ages, its all cool
Sacha Barber
A Modern Geek - I cook, I clean, I drink, I Program. Modern or what?
My Blog : sachabarber.net
|
|
|
|
|
Hi Alvaro,
Thank you very much for this implementation. I am using it and it's working great.
I am new to ASP.NET so I hope my question won't be too silly.
I have a "xxx.aspx" file and "xxx.aspx.cs" file which implement an inherit class that holds all the events for the xxx.aspx controls.
Is it passable when calling rs.Execute( " xxx.aspx.cs", "To put here a member function of the class",………)???
Or you have an idea how to work this around???
Thanks again Ziv
|
|
|
|
|
it Me again sorry for the silly question Alvaro, i found out the answer.
RS.Execute( "xxx.aspx",.....)
instead of RS.Execute( "xxx.aspx.cs",...)
Ziv
|
|
|
|
|
I have taken the RS source code and packed it into another assembly. I have also combined the client-side javascript into this assembly.
When the if(AMS.Web.RemoteScripting.InvokeMethod(Page))return; is called it writes the clientside javascript nicely into the head of the calling document. (this is so you do not have to worry about where the client side script resides etc.)
I have also written a new function / method that is a one-stop-shop remote scripting call: (see below). It allows you to define all the information and class in one easy-to-use function:
Please it inside the client side javascript file...
============================================================
============================================================
function handleRemoteScripting()
{
rs="";
rs+="RS.Execute(\""+arguments[0]+"\",";
for(o=1;o<=arguments.length;o++)
{
switch(o)
{
case 1:{
rs+="\""+arguments[1]+"\",";
break;
}
case arguments.length:{
rs+="eval("+arguments[1]+")";
break;
}
default:{
rs+="\""+arguments[o]+"\",";
break;
}
}
}
rs+=")";
eval(rs);
}
===============================================================
===============================================================
usage:
handleRemoteScripting("Default.aspx","aFunctionOrMethod","Param1","Param2");
give the Callback the same name as the server-side method name:
Client-Side:
function aFunctionOrMethod(){alert(arguments[0]);}
Server-Side:
public string aFunctionOrMethod(String Param1, String Param2)
{return Param1+Param2; // or do something else}
on the client side call / usage: (arguments are as follows)
arguments 0 = the calling document (i.e. "Default.Aspx")
arguments 1 = the client-side function / server-side method-name
(i.e. "aFunctionOrMethod")
arguments 2 and greater are all parameters passed to the server-side public method. (i.e. "Param1", "Param2")
note:
return multiple results in a comma delimited string and split the results into and array within the callback function (client-side)
**
The new RS DLL will be available shortly (with permission from AM of course)
|
|
|
|
|
Howdy Alvaro,
Well, not sure how to convey so many thanks for your library. Maybe a big THANKS... but well, still not big enough. I'd even bring some flowers but hmmm maybe better not . Anyway, thanks for such a great library; and your writing style is excellent.
You reported on an earlier comment[^] that you preferred not to use POST since there were some reports that the IE progress bar was unreliable. I ran into the same, and after making sure I was using GET and still experiencing the same issue (more or less randomly), I digged a little longer and deeper.
I found a report from MS which put me on the right track, as it explains that when a behavior is dynamically attached to a page, the progress bar, well, basically just loses it. I traced the execution and found that if I insert a "windows.status='Done'; " at the end of the setResult call (just below this.busy=false; ), the problem would be gone, and the progress bar come back to its senses; for the time being, at least.
Note that if you use "window.status=''; " ", as I wanted to, the problem remains; you have to use an actual string... sucks for other language browsers, but well, what the heck.
The MS article is: http://support.microsoft.com/kb/320731/en-us[^]
Again, thanks for the library, and everyone have a good one!
Andrés
|
|
|
|
|
Andrés
Thanks for your great comments and fix for that pesky progress bar issue.
I imagine by now you've switched over to some Ajax implementation. I've been using Anthem.NET with great satisfaction.
Regards,
Alvaro
Eat right. Exercise. Die anyway.
|
|
|
|
|
what is the advantage compare wtih ajax? ajax can do the same kind of work too.
Code killer 
|
|
|
|
|
|
General News Suggestion Question Bug Answer Joke Praise Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
|
|