您的WebService教程 [英] Your WebService Tutorial

查看:97
本文介绍了您的WebService教程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

2011年4月16日

史蒂夫,感谢您在Web服务上的文章-我几乎可以理解它(大声笑);我按照说明进行设置,是的.所以现在我有了一个很棒的例程,让我单击一个按钮并计算会话次数(点击次数),表现出色,我玩了一段时间(约4次点击),然后问了自己一个问题.我可以利用这一切吗?

我有一个包含用户数据"的文本框,当用户单击asp.net列表视图的下一页时,必须保留此数据(强制回发). Soooooo ..我如何对Web服务(会话变量)说,"helloworld"的值是文本框的内容,而在回发后(之后),文本框的值是helloworld字符串.为了使事情更加复杂,文本框是通过javascript(jquery)函数更新的,所以我猜想我必须从该函数更新helloworld变量吗?

我将非常感谢您的帮助.我已经阅读/尝试了各种动态创建会话变量的方法,例如:fred = session(''HelloWorld'').ToString;但是我只是遇到名称空间错误,并且变得越来越困惑和压力重重.感谢您阅读本文,并希望我的世界会被善良的智慧之语所照亮.关于Raymond

16/4/2011

Hi Steve, thanks for your article on the Web Service - I could nearly understand it (lol); I set up as illustrated and yep it worked. So now I have a great routine that lets me click a button and count the sessions (clicks), brilliant and I played for a while (about 4 clicks) then asked myself a question.. the question really... How in the name of all that is holy do I utilise this?

I have a textbox which contains ''user data'', this data must be retained when the user clicks next page on an asp.net listview (forces a postback). Soooooo.. How do I say to the webservice (session variable) that the value of ''helloworld'' is the content of the text box and on (after) postback the value of the textbox is the helloworld string. To maybe complicate things a bit more, the textbox is updated via a javascript (jquery) function so guess I would have to update the helloworld variable from that function?

I would really appreciate help. I''ve read / tried various methods for creating session variables on the fly, eg: fred = session(''HelloWorld'').ToString; but I just get namespace errors and am getting increasingly confused as well as stressed. THanks for reading this and hopefully my world will become illuminated by kind words of wisdom. Regards Raymond

推荐答案

无论何时回发,都应在ASP.Net应用程序中填充会话变量.这是您可以执行的操作:

Whenever the post back happens, you should populate the session variable in the ASP.Net application. This is how you can do this:

// This should be done only once and you can check first if this session variable already exists
Session.Add("TextBoxText");

// This is how you add the variable text to the session object
Session["TextBoxText"] = yourTextBox.Text;

// To access the text later, use this
string textBoxText = Session["TextBoxText"].ToString();



要在用户下次返回页面时将值保留在文本框中,可以检查会话对象中是否存在该值:



To retain the values in the textbox when the user comes back to the page next time, you can check if the value is there in the session object:

if(Session["TextBoxText"] != null){
yourTextBox.Text = Session["TextBoxText"].ToString();
}



现在,要将此值传递给Web服务,您将需要从Web服务公开的类中填充适当的属性.

顺便说一句,如果您要在CP上引用任何文章,最好在文章下方的论坛中发布,以使作者得到通知.



Now, to pass this value to the webservice, you will need to populate the appropriate property from the class that webservice exposes.

BTW, if you are referring to any article here at CP, it is better to post in the forum below the article so that the author gets notified.


这篇关于您的WebService教程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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