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
Natasa PetrovskaPosted Feb 21, 2011, 11:19 AM
Madhu KPosted Feb 21, 2011, 7:41 AM
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]);
}
}
Madhu KPosted Feb 21, 2011, 7:02 AM
protected void Page_Load(object sender, EventArgs e)
{
if (Session["s2"] != null)
{
prom = Session["s2"] as String;
}
}
function test56()
{
var linestring='<%=prom %>'
alert(linestring);
}
Natasa PetrovskaPosted Feb 21, 2011, 6:57 AM
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 KPosted Feb 21, 2011, 12:52 AM
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.