如何将值从.cs页传递到.aspx页? [英] how to pass values from .cs page to .aspx page?

查看:78
本文介绍了如何将值从.cs页传递到.aspx页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,

我有一个特殊的问题.

当用户进入我的网站时,我想在后台播放歌曲.
歌曲是根据客户机器的时间选择的.

因此,我在登录后获取客户端时间.
这会在数据库上触发查询并检索适当的歌曲.
我将这首歌存储在会话变量中.
现在,我想通过这首歌在我的欢迎页面上播放背景音乐.

所以我在aspx页面中写为.

<bgsound src=''<%=Session["song"]%>'' loop="infinite" balance="0" volume="0">

但是会话已清除,我无法播放歌曲.

这是怎么发生的?
我知道除非您这样做,否则永远不会为特定用户清除会话.

还有其他方法可以将值传递给.aspx页面吗?

请帮忙

谢谢你

Swapnil

Hie friends,

I have one peculiar problem.

I want to play songs in the background when a user enters on my site.
The song is chosen according to clients machine''s time.

So I am retrieving client side time after login.
This fires a query on database and retrieves the appropriate song.
I store this song in a session variable.
Now I want to pass this song to play in background on my welcome page.

So I write in aspx page as.

<bgsound src=''<%=Session["song"]%>'' loop="infinite" balance="0" volume="0">

But the session gets cleared and I am not able to play song.

How does this happen?
I know that session never gets cleared for a particular user unless you do it.

Is there any other way to pass value to .aspx page??

Please help

Thanking you

Swapnil

推荐答案

C#代码

受保护的字符串歌曲="a.mp3";

.aspx代码

< bgsound src =<%=歌曲%>" loop ="infinite" balance ="0" volume ="0">
C# code

protected string song = "a.mp3";

.aspx code

<bgsound src="<%= song %>" loop="infinite" balance="0" volume="0">


尝试将歌曲路径值分配给隐藏字段并使用它
Try assigning the song path value to a hidden field and use it


mmm抱歉,我看到音量等于零,对吗?
mmm srry but i see the volume is equal to zero , is that right ?


这篇关于如何将值从.cs页传递到.aspx页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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