Server control events & client scripts

  • Thread starter Thread starter Reinhold Mannsberger
  • Start date Start date
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
 
Your post went unanswered. Have you resolved this issue? If you still need
help, please post the original question with your request.
 
No, have not resolved this issue. So I'm reposting my request

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.xm
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 calle

--

The following event function would solve my problem
--
function __doPostBack(eventTarget, eventArgument)

// these and that..
theform.submit(); // -> DataGrid1_SelectedIndexChanged
is calle
doSomething(); // calling my cod

--

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top