Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Simple scripting in a web part

  Asked By: Enrique    Date: Oct 07    Category: Sharepoint    Views: 957

I'm using the Outlook Activex control in a content editor web part and it works really nice (I like the appearance much better than the OWA based My Inbox). I found some code to add two buttons to toggle between my calendar and inbox but I'm getting a script error when I select either button. Any suggestions? The object code by itself works fine.


<script id=clientEventHandlersVBS language=vbscript>
Sub btnShowCal_onclick
ViewCtlFolder.Folder = "Calendar"
End Sub

Sub btnShowEmail_onclick
ViewCtlFolder.Folder = "Inbox"
End Sub

<table class="desktopItem" border="0" width="100%" cellpadding="2" cellspacing="0" >
<td align="right"><input type="button" value="Show Calendar" name="btnShowCal">   <input type="button" value="Show Inbox " name="btnShowEmail">   </td>
<OBJECT classid="CLSID:0006F063-0000-0000-C000-000000000046" width="100%" height="350" codebase="activex.microsoft.com/.../outlctlx.cab#ver=9,0,0,3203" id=ViewCtlFolder>
<param name="Namespace" value="MAPI">
<param name="Folder" value="Inbox">
<param name="Restriction" value="">
<param name="DeferUpdate" value="0">



3 Answers Found

Answer #1    Answered By: Jerrod Collier     Answered On: Oct 07

A friend was able to supply JavaScript code  that works  great! I also added buttons  to toggle  contacts and tasks (along with inbox  and calendar)

<script language="JavaScript">
function btnShowCal_onclick() {
document.getElementById('ViewCtlFolder').folder = 'Calendar';

function btnShowEmail_onclick() {
document.getElementById('ViewCtlFolder').folder = 'Inbox';

function btnShowCont_onclick() {
document.getElementById('ViewCtlFolder').folder = 'Contacts';

function btnShowTasks_onclick() {
document.getElementById('ViewCtlFolder').folder = 'Tasks';

Answer #2    Answered By: Jacob Green     Answered On: Oct 07

Your code works  great in a .htm file, but when I place it in a content  editor
web part, it generates a script  error on the page. I found  a JavaScript
alternative that works. Thanks for your follow-up reply!

Answer #3    Answered By: Spencer Bradley     Answered On: Oct 07

I see. What happens if you click on the buttons  quickly (before the page
completes rendering)? I ran into script  errors when I clicked too quickly
even just in the HTML example.

Didn't find what you were looking for? Find more on Simple scripting in a web part Or get search suggestion and latest updates.