现在打算用sqldatareader从数据库表中读出了spot,longitude,latitude,construct,然后想传给前台,请问怎么样与javascript传递数据呢?
应该是传递数组吧。请大家爱各抒己见啊,谢谢。
另:本人是在页面上根据数据库的经纬度做一个google地图显示,遇到了这个问题。请大家指教。
应该是传递数组吧。请大家爱各抒己见啊,谢谢。
另:本人是在页面上根据数据库的经纬度做一个google地图显示,遇到了这个问题。请大家指教。
解决方案 »
- 将一文本文件内容按照指定格式逐行解析并存入指定格式数据库
- visual studio 和 oracle都安装好了 但是怎么链接啊
- 怎么让程序员不知道数据库密码,又能打包,发布?
- 如何根据用户的选择设置打印范围?
- 为什么string str="这是<script>脚本"; 输出时只显示“这是”?
- this.DataGrid1.DataKeys[(int)e.Item.ItemIndex]出错了,
- 用DataGrid显示一个动态列的结果集,怎么做???
- 用C#怎样生成html文件?
- 我的第一款共享软件,大家给点建议。
- 居然有如此Bug!!!!!!!!!!
- 哪位大哥有nurbs曲线的c#代码?
- 用非公共的可访问性添加属性访问器
{
return("a");
}<script language=javascript>
var a = "<%=str()%>";
alert(a);
</script>
C# code <%@ Page Language="C#"%><script runat="server">
public void Page_Load(Object sender, EventArgs e)
{
//声明数组名和数组值.
String arrName = "MyArray";
String arrValue = "\"1\", \"2\", \"text\"";
// Define script name and type.
String csname = "ConcatScript";
Type cstype = this.GetType();
//从当前页获取ClientScriptManager实例.
ClientScriptManager cs = Page.ClientScript; //添加数组声明.
cs.RegisterArrayDeclaration(arrName, arrValue); // Check to see if the script is already registered.
if (!cs.IsClientScriptBlockRegistered(cstype, csname))
{
StringBuilder cstext = new StringBuilder();
cstext.Append("<script type=text/javascript> function DoClick() {");
cstext.Append("Form1.Message.value='Sum = ' + ");
cstext.Append("(parseInt(" + arrName + "[0])+");
cstext.Append("parseInt(" + arrName + "[1])+");
cstext.Append("parseInt(" + Form1.Name + "." + hiddenName + ".value));} </");
cstext.Append("script>");
cs.RegisterClientScriptBlock(cstype, csname, cstext.ToString(), false);
}
}
</script>
<html>
<head>
<title>ClientScriptManager Example</title>
</head>
<body>
<form id="Form1"
runat="server">
<input type="text"
id="Message" />
<input type="button"
onclick="DoClick()"
value="Run Script">
</form>
</body>
</html>
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Clear();
System.Web.HttpContext curContext = System.Web.HttpContext.Current; Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
Response.Charset = "UTF-8";
curContext.Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
GridView1.AllowPaging = false;
BindData();
GridView1.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
GridView1.AllowPaging = true;
BindData(); }
private void BindData()
{
GridView1.DataBind();
}
public override void VerifyRenderingInServerForm(Control control)
{
// Confirms that an HtmlForm control is rendered for
}}