如何在 URL 中传递数据
如何通过我的 URL 传递数据?
我需要传递电子邮件、client_id 等。
Client.aspx?Email='[email protected]'
现在我有一个 Javascript 函数,但我认为通过代码隐藏会更好
$('.btIncluirAtendimento').live('click', function () {
idCliente = $(this).attr('id').replace('cad_', '');
popup = openPopup('../Cliente/AtendimentoNew.aspx?Cliente_Id=' + idCliente, 'IncluirAtendimento', 'toolbar=no,directories=no,status=no,menubar=no, scrollbars=yes,resizable=no', '720', '600', 'true');
});
function openPopup(theURL, winName, features, myWidth, myHeight, isCenter) {
if (window.screen) if (isCenter) if (isCenter == "true") {
var myLeft = (screen.width - myWidth) / 2;
var myTop = (screen.height - myHeight) / 2;
features += (features != '') ? ',' : '';
features += ',left=' + myLeft + ',top=' + myTop;
}
popup = window.open(theURL, winName, features + ((features != '') ? ',' : '') + 'width=' + myWidth + ',height=' + myHeight);
return popup;
}
有人能帮助我吗?
How can I pass data through my URL ?
I need to pass, an email, client_id, etc.
Client.aspx?Email='[email protected]'
Nowadays I have an Javascript Function, but I think would be better via Code-Behind
$('.btIncluirAtendimento').live('click', function () {
idCliente = $(this).attr('id').replace('cad_', '');
popup = openPopup('../Cliente/AtendimentoNew.aspx?Cliente_Id=' + idCliente, 'IncluirAtendimento', 'toolbar=no,directories=no,status=no,menubar=no, scrollbars=yes,resizable=no', '720', '600', 'true');
});
function openPopup(theURL, winName, features, myWidth, myHeight, isCenter) {
if (window.screen) if (isCenter) if (isCenter == "true") {
var myLeft = (screen.width - myWidth) / 2;
var myTop = (screen.height - myHeight) / 2;
features += (features != '') ? ',' : '';
features += ',left=' + myLeft + ',top=' + myTop;
}
popup = window.open(theURL, winName, features + ((features != '') ? ',' : '') + 'width=' + myWidth + ',height=' + myHeight);
return popup;
}
Can anyone help me ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你走在正确的轨道上。首先,对值进行 URL 编码,如下所示。 (对数字进行编码不会执行任何操作,因此如果所有客户端 ID 都是数字,则可以省略第二个 UrlEncode。)
这将为您提供以下 url:
您可以使用以下代码行读取 Client.aspx.cs 中的值:
记住检查参数。如果 ClientId 不是数字,Int32.Parse() 将抛出异常。
You are on the right track. First, URL-encode the values, like this. (Encoding a number will not do anything, so the second UrlEncode could be left out if all client IDs are numbers.)
This will give you this url:
You can read the values in Client.aspx.cs with these line of code:
Remember to check parameters. Int32.Parse() will throw an exception if ClientId is not a number.
您需要对 url 字符串进行编码,然后才能轻松传递数据。
例子 :
You need to encode the url string and than you can pass data easily.
Example :
您必须对关键字符进行编码。请在此处查看字符说明。您的网址必须如下所示:
You'll have to encode the critical characters. Look here for a desacription the characters. Your URL has to look like this:
http://msdn.microsoft.com/en-us/library/4fkewx0t.aspx
http://msdn.microsoft.com/en-us/library/4fkewx0t.aspx