R
Reinhold Mannsberger
Hello!
I have a page with a datagrid, where the user can select
an item. Based on the selection of the user, a xml-file is
generated. Some values of the xml-file should be passed to
an application via javascript.
This is what I have done:
--- the source file ---
private void DataGrid1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
// generate MyDocument.xml
string scriptString = "\n<script language=\"javascript\"
id=\"execCodeJS\">\n" +
"doSomething();\n</script>\n";
if (IsClientScriptBlockRegistered("execCodeJS") == false)
{
this.RegisterClientScriptBlock("execCodeJS",
scriptString);
}
}
------
--- the aspx page ---
<xml id="selectionXML" src="MyDocument.xml" />
<script language="javascript" id="clientEventHandlersJS">
function doSomething()
{
var xmlNode;
xmlNode = selectionXML.XMLDocument.selectSingleNode
("these/and_that"); +
alert(xmlNode.text);
}
</script>
------
Unfortunately this does not work.
---
Error: the data necessary to complete this operation is
not yet available.
---
When clicking a button with onclick="doSomething()", the
problem does not occur, everything works fine.
The user selection in the datagrid triggers an event
function.
---
function __doPostBack(eventTarget, eventArgument)
{
// these and that...
theform.submit(); // -> DataGrid1_SelectedIndexChanged
is called
}
---
The following event function would solve my problem:
---
function __doPostBack(eventTarget, eventArgument)
{
// these and that...
theform.submit(); // -> DataGrid1_SelectedIndexChanged
is called
doSomething(); // calling my code
}
---
But how can I get this done?
I am relatively new into web programming, so if there is
better way for solving my problem, please tell me.
Thanks in advance,
Reinhold
I have a page with a datagrid, where the user can select
an item. Based on the selection of the user, a xml-file is
generated. Some values of the xml-file should be passed to
an application via javascript.
This is what I have done:
--- the source file ---
private void DataGrid1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
// generate MyDocument.xml
string scriptString = "\n<script language=\"javascript\"
id=\"execCodeJS\">\n" +
"doSomething();\n</script>\n";
if (IsClientScriptBlockRegistered("execCodeJS") == false)
{
this.RegisterClientScriptBlock("execCodeJS",
scriptString);
}
}
------
--- the aspx page ---
<xml id="selectionXML" src="MyDocument.xml" />
<script language="javascript" id="clientEventHandlersJS">
function doSomething()
{
var xmlNode;
xmlNode = selectionXML.XMLDocument.selectSingleNode
("these/and_that"); +
alert(xmlNode.text);
}
</script>
------
Unfortunately this does not work.
---
Error: the data necessary to complete this operation is
not yet available.
---
When clicking a button with onclick="doSomething()", the
problem does not occur, everything works fine.
The user selection in the datagrid triggers an event
function.
---
function __doPostBack(eventTarget, eventArgument)
{
// these and that...
theform.submit(); // -> DataGrid1_SelectedIndexChanged
is called
}
---
The following event function would solve my problem:
---
function __doPostBack(eventTarget, eventArgument)
{
// these and that...
theform.submit(); // -> DataGrid1_SelectedIndexChanged
is called
doSomething(); // calling my code
}
---
But how can I get this done?
I am relatively new into web programming, so if there is
better way for solving my problem, please tell me.
Thanks in advance,
Reinhold