Hi,
I have a comaseparated list ( ex. 41.9924 21.4648, 41.9907 21.4704, 41.9895 21.4767, 41.987 21.4638 ) and I want to pass it from the web behind code of the first web form (it is in a textbox of the first web form) in the javascript code of the second web form.
Can anybody help me please?
Loading

Madhu KRank #1,514 · 1.1K reputationPosted Feb 20, 2011, 7:52 PM EST
Declare the string as public
public string str = "1,2,2,3,4,4,5,";
js function:
function test56()
{
var temp='<%=str %>'
alert(temp);
}
Onclick of the button you can access the str value.
Natasa Petrovska5 reputationPosted Feb 21, 2011, 1:57 AM EST
List LineLista = new List();
foreach (GridViewRow row in GridView1.Rows)
{
LineLista.Add(row.Cells[3].Text + " " + row.Cells[4].Text);
}
string LineList = string.Join(",", LineLista.ToArray());
txtLineList.Text = LineList;
......
.....
...
protected void Button2_Click(object sender, EventArgs e)
{
Session["s2"] = txtLineList.Text;
Response.Redirect("GELinija.aspx");
}
Now I don't understand well what should I do? Where to declare the string as public and what should I do in the second web form?
I use this in the second web form:
protected void Page_Load(object sender, EventArgs e)
{
if (Session["s2"] != null)
{
string prom = Session["s2"] as String;
}
}
and then in the javascript I have:
<
script type="text/javascript">var lineString= prom;
but I got an error that prom is undefined
Madhu KRank #1,514 · 1.1K reputationPosted Feb 21, 2011, 2:02 AM EST
protected void Page_Load(object sender, EventArgs e)
{
if (Session["s2"] != null)
{
prom = Session["s2"] as String;
}
}
function test56()
{
var linestring='<%=prom %>'
alert(linestring);
}
Madhu KRank #1,514 · 1.1K reputationPosted Feb 21, 2011, 2:41 AM EST
Check this function to split.
function test56()
{
var spli="te,st,sp,tl,it";
var spl=spli.split(",");
for(i=0;i
alert(spl[i]);
}
}
Natasa Petrovska5 reputationPosted Feb 21, 2011, 6:19 AM EST