I have this asp.net code that is connecting to a database and creating list, which then is displayed by javascript in an alert message box on startup.
Here's my asp.net code
Currently it this javascript is creating the alert:
I would like modify my asp.net code and create a new javascript that just captures the list (array) and returns it when called. Something like this; but this doesn't work:
Can someone guide me.
Thanks
Here's my asp.net code
Code:
<%
DataSourceSelectArguments args = new DataSourceSelectArguments();
// Convert SqlDataSource to a DataView variable.
DataView view = (DataView)this.GPROD10_PD_MIS.Select(args);
DataTable dt = view.ToTable();
ArrayList list = new ArrayList();
for (int i = 0; i < dt.Rows.Count; i++)
{
list.Add(dt.Rows[i]["CODE"]);
}
string values = string.Join(",", (string[])list.ToArray(typeof(string)));
// Pass the value to javascript function.
Page.ClientScript.RegisterStartupScript(this.GetType(), "Jay", "GetValue('" + values + "')", true);
%>
Code:
<script language="javascript" type="text/javascript">
function GetValue(list) {
alert(list);
}
</script>
I would like modify my asp.net code and create a new javascript that just captures the list (array) and returns it when called. Something like this; but this doesn't work:
Code:
<script language="javascript" type="text/javascript">
function GetValue2(list) {
return list;
}
</script>
Can someone guide me.
Thanks