Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to place a SP aspx variable in a javascript

Posted on 2011-04-28
10
Medium Priority
?
510 Views
Last Modified: 2012-08-14
I use a javascript called overlib which does a really nice job on mouse over pop-ups.

The format for overlib is like this in your apsx
<a href="javascript:void(0);" onmouseover="return overlib('pop-up text', FGCOLOR, '#ffff99', BGCOLOR, '#d8d8d8');" onmouseout="return nd();">fieldtopopon</a>

the question is how can I get sp aspx field request_x0020_Detail into the pop-up text space?

<SharePoint:FormField runat="server" id="ff8{$Pos}" ControlMode="New" FieldName="Request_x0020_Detail" __designer:bind="{ddwrt:DataBind('i',concat('ff8',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Request_x0020_Detail')}"/>

tried
<a href="javascript:void(0);" onmouseover="return overlib({@Request_x0020_Detail}, FGCOLOR, '#ffff99', BGCOLOR, '#d8d8d8');" onmouseout="return nd();"><xsl:value-of select="@Covers" /></A>
but gets an error Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Windows SharePoint Services-compatible HTML editor such as Microsoft Office SharePoint Designer. If the problem persists, contact your Web server administrator.





0
Comment
Question by:Matt Pinkston
  • 5
  • 5
10 Comments
 
LVL 12

Expert Comment

by:mwochnick
ID: 35485772
where in the sharepoint aspx are you putting your href tag? and how are you doing this? are you using sp designer? etc I need more context to understand the problem
0
 

Author Comment

by:Matt Pinkston
ID: 35487007
yes it is spdesigner 2007

i attached a snippet of the code
<xsl:value-of select="@Request_x0020_Type" /></td><td class="style29" style="text-align: center; background-color: #FFFFFF; width: 12%;">
				<xsl:value-of select="format-number(@Ammount, &quot;$#,##0.00;-$#,##0.00&quot;)" /></td><td class="style29" style="background-color: #FFFFFF; width: 117px; text-align: center;">
				<xsl:value-of select="@status"/>
			</td><td class="style29" style="background-color: #FFFFFF"><a href="javascript:void(0);" onmouseover="return overlib('mouse over for details about this request', FGCOLOR, '#ffff99', BGCOLOR, '#d8d8d8');" onmouseout="return nd();"><xsl:value-of select="@Covers" /></a></td><td class="style36" style="background-color: #FFFFFF"><xsl:value-of select="@Approver_x0028_s_x0029_" disable-output-escaping="yes" /></td></tr>

Open in new window

0
 
LVL 12

Expert Comment

by:mwochnick
ID: 35491666
still hard to tell, based on context, but given the error and what you've given it appears that the webpart xslt processor can't handle the change you are introducing into the data that the webpart is using to render the html.   - it looks like you are trying to modify the behavior of the webpart to change the dsiplay to use a javascript list item - what webpart are you using and how are you attempting to modify it may be that you need to find a different webpart
0
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 

Author Comment

by:Matt Pinkston
ID: 35493075
okay well the javascript works fine if it is placed this way

The format for overlib is like this in your apsx
<a href="javascript:void(0);" onmouseover="return overlib('pop-up text', FGCOLOR, '#ffff99', BGCOLOR, '#d8d8d8');" onmouseout="return nd();">fieldtopopon</a>

But when I try to replace "pop-up text" with {@Request_x0020_Detail} is when I get the error
0
 
LVL 12

Expert Comment

by:mwochnick
ID: 35493870
I think I'm getting what you are attempting. You want your javascript popup to look as some field - that is generated by the webpart - currently you are trying to access this via @Request_x0020_Detail -- i'm guessing this is a server side item that has two issues - 1. it confuses the webpart because its trying to do something serverside with that Item and its not in the right place for the webpart. 2. your client javascript code can't use this because its a server side tag that is used to produce html.

You need your javascript to access something that is in the rendered html - not the aspx server side code.  run your page without the @Request... view the page and the source code of the page to determine the element name you need to access and then use javascript to get the correct item

if you look at the page below there are a couple of alert items under the Document section that show how to get html items in javascript
http://www.w3schools.com/js/js_ex_dom.asp
0
 

Author Comment

by:Matt Pinkston
ID: 35495602
I guess I don't follow, I am just trying to get the value of that field to pop-up when I hover over that link.  That is what overlib does.
0
 
LVL 12

Expert Comment

by:mwochnick
ID: 35495823
yes overlib is javascript and runs in the browser you are using sharepoint designer to edit a sharepoint aspx page that runs on the server to produce the html/javascript to run in your browser.  the modifications you are making to the aspx is causing the server side code to break.  

the variable you are trying to use in your javascript is server side code.  You need your javascript to use the results of the server side code in your browser. - does this make sense?
0
 

Author Comment

by:Matt Pinkston
ID: 35504453
somewhat, so how do I get around it?  do I store the value into a variable first?
0
 
LVL 12

Accepted Solution

by:
mwochnick earned 2000 total points
ID: 35505054
Sharepoint is built on ASP.NET a server side processing technology that can output html.  The syntax of ASP.NET pages is similar to html.  Now if you built an ASP.NET page that would show the current time everyitme the page is refreshed. It would display the time of server.

If you used javascript to display the current time, it would show the time of your computer

Here's a tutorial on ASP and ASP.NET
http://www.w3schools.com/aspnet/aspnet_pages.asp

To solve your problem
1 you need to browse to your sharepoint page that displays with overlib hardcoded with the "pop up text"
2. view the source - from your web browser and save it to an html file
3. make overlib work in as desired in the html file  - working from your local drive - not sharepoint
4. determine how to make it work in your sharepoint page - to help you determine this, it will require much more of the source code from the aspx (from sharepoint designer) and the source code from the html file

essentially what you need to do is determine the name of the output html element you wish to use after sharepoint processes the file and then modify the aspx file to use that name and not interfere with the webpart
0
 

Author Comment

by:Matt Pinkston
ID: 35780165
i will check the proposed answer
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you create your solutions on SharePoint sooner or later you will come upon a request to set  permissions of the item depending on some of the item's meta-data - the author, people assigned as approvers, divisions, categories etc. The most natu…
Microsoft SharePoint Foundation 2010 and Microsoft SharePoint Server 2010 do not offer the option to configure the location of the SharePoint diagnostic trace log files during installation.  This can, however, be configured through Central Administr…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question