using javascrip with datagrid

  • Thread starter Thread starter Brett Wesoloski
  • Start date Start date
B

Brett Wesoloski

I can not seem to figure this out, but really haven't work a lot with
javascrip and .NET.

I have a data grid and I want to put a button in it and when the button is
pressed it will call my javascript. Now the grid is in a .ascx file. The
other kicker is I want to also use the databinder property to get a value as
the grid is loading and use that in my java script.

Here is what I have so far as for getting the javascript to do what I want.
the file variable is what needs to use databinder. I guess that is the part
I don't understand. Any help would be greatly appreciated.

TIA,
Brett

<html>
<head>
<script language="JavaScript" type="text/JavaScript">
<!-- Enable Stealth Mode
// Variable Definitions
var nameSpace = null;
var mailFolder = null;
var mailItem = null;
var tempDoc = null;
var outlookApp = null;
var file = null;
var filename = null;
function OpenOutlookDoc(whatform)
{
try
{
file = '\\\\planadmininc.com\\Shareddata\\4most\\proposals\\M\\ABC
Company, Inc. Safe Harbor 401(k) PS Plan_2.pdf'; (THIS IS WHAT NEEDS TO USE
THE DATABINDER)
filename = 'myfile';
outlookApp = new ActiveXObject("Outlook.Application");
nameSpace = outlookApp.getNameSpace("MAPI");
mailFolder = nameSpace.getDefaultFolder(6);
mailItem = mailFolder.Items.add(whatform);
mailItem.To = "(e-mail address removed)";
mailItem.Subject = 'test subject';
mailItem.Body = 'test body';
mailItem.Attachments.Add(file);
mailItem.Display(0)
}
catch(e)
{
// act on any error that you get
}
}
// Disable Stealth Mode -->
</script>
</head>
<body>
<form>
<input type=button value="Send Email" NAME="OutlookOpen1"
OnClick="OpenOutlookDoc('IPM.NOte.FormA')"><br><br>
</form>
</body>
</html>
 
Hi,


You can use a Templatecolumn and then you can customize the content of it.

Or you can use the Item_DataBound and modify the client onclick event.
 
I have been trying to use the template column with not much luck. Well the
page loads but when the button is clicked it doesn't do anyting.

This is what I have for my template column
<asp:TemplateColumn HeaderText="E-Mail Proposal"
ItemStyle-HorizontalAlign="Center">

<ItemTemplate>

<input type="button" name="email" value= "EMail"
onclick="OpenOutlookDoc('IPM.Note.FormA', '<%#
(DataBinder.Eval(Container.DataItem, "FilenameURL").ToString()) %>')" />

</ItemTemplate>

</asp:TemplateColumn>



Then above in the .ascx I have

<script language="JavaScript" type="text/JavaScript">

<!-- Enable Stealth Mode

// Variable Definitions

var nameSpace = null;

var mailFolder = null;

var mailItem = null;

var tempDoc = null;

var outlookApp = null;

var filename = null;

function OpenOutlookDoc(whatform, file)

{

try

{

filename = 'myfile';

outlookApp = new ActiveXObject("Outlook.Application");

nameSpace = outlookApp.getNameSpace("MAPI");

mailFolder = nameSpace.getDefaultFolder(6);

mailItem = mailFolder.Items.add(whatform);

mailItem.To = "(e-mail address removed)";

mailItem.Subject = 'test subject';

mailItem.Body = 'test body';

mailItem.Attachments.Add(file);

mailItem.Display(0)

}

catch(e)

{

// act on any error that you get

}

}

// Disable Stealth Mode -->

</script>



Any idea's why nothing is coming up?



TIA,
Brett
 
Hi,

What you see when you select View Source in IE?

Do you get any error? (A yellow icon in the left botton corner of the
browser)
 

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