Bran-Damage
asked on
create a for each loop for javascript in c#
I need to create a for each loop for javascript in my c# code.
I have a list variable. I want to pass this into my java script, and then when my java script gets fired off, i want it to go through the list and do something.
Basically i need to iterate through the lstStrLabels list. and during each iteration, i need to grab the string value out of it, and put it in the sprint.pagecreate(....) function and pImage will be the value that is in the element in the array for the current itteration.
I am building this string i c#, and then I am passing it to my registerstartupscript.
I have a list variable. I want to pass this into my java script, and then when my java script gets fired off, i want it to go through the list and do something.
Basically i need to iterate through the lstStrLabels list. and during each iteration, i need to grab the string value out of it, and put it in the sprint.pagecreate(....) function and pImage will be the value that is in the element in the array for the current itteration.
I am building this string i c#, and then I am passing it to my registerstartupscript.
StrImage += "<script type=\"text/javascript\" language=\"javascript\">";
StrImage += "var Sprint = document.getElementById(\"printdocument\");";
StrImage += "var prname='" + subObj.strPrinterName + "';";
StrImage += "var pImage='" + lstStrLabels + "';";
StrImage += "var pNoCopies='" + subObj.iNoOfPrints.ToString() + "';";
StrImage += "var Weg= SPrint.pagecreate(pImage, prname, pNoCopies);";
StrImage += "</script>";
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
so this seems like it might be working, but I keep getting an error message when the java fires off that I have an Invalid character in a Base-64 string.
lstStrLabels is a list that I added a bunch of base-64 strings to.
lstStrLabels is a list that I added a bunch of base-64 strings to.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
We are going to use a different route for this.
As the author pointed out in #33170778:
>>so this seems like it might be working, but I<<
The encoding is really a separate issue, and if the author decides to go another way rather than implementing a follow up suggestion, that is certainly an option, but should not negate that my solution was at least sufficient for the information as posted (originally).
>>so this seems like it might be working, but I<<
The encoding is really a separate issue, and if the author decides to go another way rather than implementing a follow up suggestion, that is certainly an option, but should not negate that my solution was at least sufficient for the information as posted (originally).
The solution I posted #33168202 would solve the (first) issue. I also followed up with 33171705 as a suggestion to fix any odd characters.
ASKER
Note: I am writing this in c# for java.
Open in new window