PDA

View Full Version : OnItemCommand event in DataGrid & Session Variables in a CSS


jwite2003
04-01-2003, 08:53 PM
Hi,

Two quick questions. How does the OnItemCommand DataGrid event work? I was trying to use it to call a JavaScript function, but keep getting the following error message:

Compiler Error Message: CS0117: 'ASP.WebForm2_aspx' does not contain a definition for 'ShutWin'

Here's the 'ShutWin' Function code:
function ShutWin()
{
self.close();
}

I have also tried it with window.close() in place of self.close()
Both ways I get the same error message. I have also tried calling window.close() & self.close() when the OnItemCommand event occurs... In this case I get:

window not defined or self not defined respectively.

My second question is if it is possible to set a session variable inside the <Script Language=Javascript></Script> tags?

I'm working in ASP.NET(Visual C# code behind).
ASP.WebForm2_aspx is being generated from window.open('WebForm2.aspx') in WebForm1.aspx.

Thanks in advance for any insights,

whammy
04-02-2003, 12:18 AM
Can I see the client-side code that's generated?

allida77
04-02-2003, 02:41 PM
The OnItemCommand alows you to add your own commands to buttons,image buttons, ect to a datagrid. So if I add a button then onClick I will run the specific command which would be adding javascript to the button attribute. Post your datagrid code from your aspx page and the void dg_Command {} in your code behind.

jwite2003
04-02-2003, 08:03 PM
thanks allida, your post gave me a good idea for a work around to my problem.

I was originally hoping to call both the void dg_Command {} function in the code behind(to run some database select statements) and a javascript function(to close the WebForm2.aspx window and return to the WebForm1.aspx window) when one of the button columns was clicked on. I couldn't find a good way to call the javascript function from inside the code behind function or to call the code behind function from inside the javascript function.

So I ended up linking the void dg_Command{} function to the OnItemCommand event and added a separate button to call the javascript function when clicked. Problem Solved.

Cheers Mates,