Control help....not sure what to do ??

Sep 19 2007 5:38 AM

hi,

i'm pretty new to all this so excuse if this is a silly question. I have trawled google but havnt found a direction which convinces me yet.

I need to develop some sort of control that can be wrapped in a webpart and used on sharepoint site. This control should launch a new infopath form based on an existing template and pre-populate a field on that form.

I have developed javascript that does this and simply saved it as an html page attaching the script to a button click to prove it works:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test bit of javascript page</title>
<script type="text/javascript">
function myfunction()
{
 var strHRef= window.location.href;
 var subString = strHRef.substr(strHRef.indexOf("Proposal"));
 var splitstring = subString.split("/");
 var strReturn = splitstring[1];
 return(strReturn);
 
}
</script>
</head>
<body>

<script type="text/javascript">
function openInfoPathPopulated()
{
 
 var ProjID = myfunction();
 

 var oApp = new ActiveXObject("InfoPath.Application");
 
 var oXDocument = oApp.XDocuments.NewFromSolution("thepath"); 

 var targetField1 = oXDocument.DOM.selectSingleNode("thefield");

 targetField1 = ProjID;

}
</script>

<form>
<input type="button" onclick="openInfoPathPopulated()" value="Call function"/>

</form>

</body>
</html>

My problem now is to create the control. Should i be using a custom web control, a user control etc ... I'm a bit stuck on how to achieve my aim. I know what i need to do but dont know how !!

Hope someone can give me some advice / code snipppets or point me to a good tutorial.

thanks

Graham