将字符串从客户端移动到服务器(JS - > ASPX) [英] Moving a string from client to server (JS -> ASPX)

查看:67
本文介绍了将字符串从客户端移动到服务器(JS - > ASPX)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在client.js文件中,我声明

跟随变量。


...

var str =" ; info" ;;

...

在相应的ASP文件中,名为

server.aspx.cs我声明了两个以下

方法。


...

protected void Page_Load(

对象发送者,EventArgs e ){...}

public void SomeThing(){

...

字符串数据;

......}

...


目标是_SOMEHOW_确保

表示数据的价值(在CS中)文件)

是从str获得的(在JS文件中)。


请注意,我不需要数据
$ b一旦str改为
,$ b就会动态更新。每次我们传递

部分代码时,只需调用

" info"

" info" ;到str。


另请注意我需要通知

SomeThing关于str的值。


Of当然,实际情况很远

更复杂但我的问题可以是

归结为这个简单的案例。


如何应该设计SomeThing吗?怎么

需要我重建行后

赋值给str?


-

问候

Konrad Viltersten

------------------------------ -

睡觉 - 为穷人替代咖啡

野心 - 缺乏懒惰感

In the client.js file i declare the
following variable.

...
var str = "info";
...

In the corresponding ASP file called
server.aspx.cs i declare two following
methods.

...
protected void Page_Load (
object sender, EventArgs e){...}
public void SomeThing () {
...
String data;
...}
...

The objective is to _SOMEHOW_ ensure
that the value of data (in the CS file)
is obtained from str (in the JS file).

Note that i don''t need data to be
dynamically updated as soon as str is
changed. It''s sufficient to call the
method SomeThing each time we pass the
part of code where we assign the value
"info" to str.

Note also that i need to notify
SomeThing about the value of str.

Of course, the actual situation is far
more complicated but my problem can be
boiled down to this simple case.

How should SomeThing be designed? How
need i to reconstruct the lines after
the assignment to str?

--
Regards
Konrad Viltersten
--------------------------------
sleep - a substitute for coffee for the poor
ambition - lack of sense to be lazy

推荐答案

K Viltersten写道:
K Viltersten wrote:

在client.js文件中,我声明

跟随变量。


...

var str =" info";

...


在相应的名为

server.aspx.cs的ASP文件中,我声明了两个

方法。


。 ..

protected void Page_Load(
object sender,EventArgs e){...}

public void SomeThing(){

...

字符串数据;

...}

...


目标是_SOMEHOW_确保

数据的值(在CS文件中)

是从str获得的(在JS文件中)。


注意我不需要数据

一旦str改变就动态更新。
改变了。每次我们传递

部分代码时,只需调用

" info"

" info" ;到str。


另请注意,我需要通知

SomeThing有关str的值。
In the client.js file i declare the
following variable.

...
var str = "info";
...

In the corresponding ASP file called
server.aspx.cs i declare two following
methods.

...
protected void Page_Load (
object sender, EventArgs e){...}
public void SomeThing () {
...
String data;
...}
...

The objective is to _SOMEHOW_ ensure
that the value of data (in the CS file)
is obtained from str (in the JS file).

Note that i don''t need data to be
dynamically updated as soon as str is
changed. It''s sufficient to call the
method SomeThing each time we pass the
part of code where we assign the value
"info" to str.

Note also that i need to notify
SomeThing about the value of str.



如果没有其他HTTP请求(可以是XHR)就无法完成,因为两个

彼此不了解。如果你现在还不知道,你应该首先获得关于客户端 - 服务器架构的一些基本知识,然后再用它们搞砸




您的帖子不容易辨认。代词我总是拼写为

大写字母,你的行长约为预期的一半
使用网络中的
(建议每行80个字符)最大值,72到78到

允许报价而无需重新格式化)。此外,在顶级

层次结构上交叉发布是不明智的,因为新闻服务器可能在Big 8中有comp。*
(Usenet)但不包括microsoft。*不属于那个。所以

的讨论会变得支离破碎,TLH中的沟通惯例

也可能不同。


见还可以 http://jibbering.com/faq/

后续修剪到cljs


PointedEars

-

Prototype.js是由不懂javascript的人写的适合人们

谁不懂javascript。不知道javascript的人不是设计使用javascript的系统的最佳建议来源。

- Richard Cornford,cljs,< f8 ** *****************@news.demon.co.uk>

It cannot be done without another HTTP request (can be XHR) because the two
don''t know about each other. If you don''t know that by now, you should get
some basic knowledge about client-server architectures first, before messing
around with them.

Your posting was not easily legible. The pronoun `I'' is spelled with a
capital letter always and your line length is about half of what is expected
in Usenet (80 characters per line is the recommended maximum, 72 to 78 to
allow for quotation without reformat). Also, cross-posting over top-level
hierarchies is unwise as a news server may have comp.* within the Big 8
(Usenet) but not microsoft.* which does not belong to that. So the
discussion is going to be fragmented, and the conventions of communication
in the TLHs may also differ.

See also http://jibbering.com/faq/
Followup trimmed to c.l.js

PointedEars
--
Prototype.js was written by people who don''t know javascript for people
who don''t know javascript. People who don''t know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>


>在client.js文件中我声明
>In the client.js file i declare the

>以下变量。

...
var str =" ; info" ;;
...

在相应的ASP文件中,名为
server.aspx.cs我声明了以下两种
方法。

...
protected void Page_Load(
object sender,EventArgs e){...}
public void SomeThing(){
...
String数据;
......}


目标是_SOMEHOW_确保
数据的价值(在CS文件中)
是从str获得的(在JS文件中)。
>following variable.

...
var str = "info";
...

In the corresponding ASP file called
server.aspx.cs i declare two following
methods.

...
protected void Page_Load (
object sender, EventArgs e){...}
public void SomeThing () {
...
String data;
...}
...

The objective is to _SOMEHOW_ ensure
that the value of data (in the CS file)
is obtained from str (in the JS file).



没有其他HTTP请求(可以是XHR)就无法完成,因为

TW哦

彼此不了解。如果你现在还不知道,你应该先获得一些关于客户端 - 服务器架构的基本知识,然后才能获得

搞乱

与他们在一起。

It cannot be done without another HTTP request (can be XHR) because the
two
don''t know about each other. If you don''t know that by now, you should
get
some basic knowledge about client-server architectures first, before
messing
around with them.



谢谢!试着不要不礼貌我仍然需要指出问题

是怎么做,而不是相反。您是否建议

是从

服务器请求(另一个)页面的唯一(推荐)方式?当然,这在我的情况下是可行的,但我不想使用 file.aspx?str = infotarget =_ blank> http://.../file.aspx?str = info


也许我可以烘烤它在发件人对象中。你觉得怎么样?


-

问候

Konrad Viltersten

---- ----------------------------

睡觉 - 为穷人替代咖啡

野心 - 缺乏懒惰感


Thanks! Trying not to be impolite i still need to point that the question
was "how can it be done", not the opposite. Are you suggesting that
the only (recommended) way to to request (another) page from the
server? It would be doable in my case, of course, but i''d prefer not to
send in the string using http://.../file.aspx?str=info.

Perhaps i could bake it in the sender object. What do you think?

--
Regards
Konrad Viltersten
--------------------------------
sleep - a substitute for coffee for the poor
ambition - lack of sense to be lazy


5月18日下午3:42,K Viltersten < t ... @ viltersten.comwrote:
On May 18, 3:42 pm, "K Viltersten" <t...@viltersten.comwrote:

您是否建议

唯一(推荐)方式请求(另一个) )

服务器的页面?
Are you suggesting that
the only (recommended) way to to request (another) page from the
server?



欢迎使用HTTP ;-)这是一个无状态协议,因此在页面为客户端提供
后,有_no_连接

页面与服务器之间的任何类型:无。

HTTP之后的唯一通信方式是新请求

已启动由客户端:服务器无法发起任何事情。

Welcome to HTTP ;-) It is a stateless protocol, so after the page is
served to the client, there is _no_ connection of any kind between the
page and the server: none.
The only way of communication HTTP has after that is a new request
initiated by the client: the server has no way to initiate anything.


当然,在我的情况下这是可行的,但我不想

使用 http:// ...发送字符串/file.aspx?str=info



你不必这样做。使用AJAX或ol''ood隐藏的iframe

连接到服务器并报告新的src值。

You don''t have to do that. Use AJAX or ol''good hidden iframe to
connect to the server and to report new src values.


这篇关于将字符串从客户端移动到服务器(JS - &gt; ASPX)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆