Click here to Skip to main content
15,914,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to pass the list of values stored in variable "id " in .cs page to view page as javascript function.
////////////////////cs page code
private void RenderTables()
{

foreach (DataRow dr in dtid.Rows)
{
string id = dr["BERSubAccountsId"].ToString();
ScriptManager.RegisterStartupScript(this, this.GetType(), "onUpdate()", "InvokeSummary(" + id + ");", true);

}
//////////////

from cs page we get values as id= 1234567891011
but this set of values didn't pass to view page javascript, it pass only last value

What I have tried:

we have tried to pass this id as an array but it was also gave same as previous result
Posted
Updated 13-Jun-19 23:53pm

1 solution

The third parameter (onUpdate()) is the key, so if you add 5 things you have the same key 5 times, but keys are unique so asp.net only keeps one and discards the rest. If you want to add multiple times you need a unique key. If "id" is unique each time you could just use that

ScriptManager.RegisterStartupScript(this, this.GetType(), "onUpdate_" + id, "InvokeSummary(" + id + ");", true);


If "id" isn't unique then just have an int value that you increment in the loop and use that instead.
 
Share this answer
 
Comments
Member 13854008 14-Jun-19 6:18am    
actually our question is how to pass this value to view page in javascript function
F-ES Sitecore 14-Jun-19 6:41am    
There is probably issues with your javascript as well but it's impossible to say what as you haven't posted the relevant code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900