I'm trying to embed google docs viewer in my page.
Here's the test.aspx code:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="Web_Application.test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<iframe id="documentLoader" src="https://docs.google.com/viewer?embedded=true&url=http://view.samurajdata.se/license.pdf"
style="width:100%; height:800px;">
</iframe>
</body>
</html>
Here's my test.aspx.cs
namespace Web_Application
{
public partial class test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
I get errors such as
'Line: 409
Error: Unable to get value of the property 'k': object is null or undefined'
or
'Line: 458
Error: Unable to get value of the property 'a': object is null or undefined'
which are from google doc viewer online javascript resource...
So I embedded the script in the header and it worked. But the problem is, if I do this in a user control or in a page inherited from a master page I get those errors again.
How can I solve this?
Thank you.
try this iframe script independent of any browser or version this will work ....
<iframe id="documentLoader" src="https://docs.google.com/viewer?url=http://view.samurajdata.se/license.pdf&chrome=true" style="width: 100%; height: 800px;">
</iframe>
mark yes if works !!! :)
<iframe id="documentLoader"
src="https://docs.google.com/viewer?url=http//view.samurajdata.se/license.pdf&embedded=true"
style="width:100%; height:800px;">
Related
I got an ASPX page with the folowing code behind
public partial class test : Page
{
protected void test(object sender, EventArgs e)
{
throw new Exception("test");
}
}
And the following ASPX code:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="test" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Thumbnail</title>
</head>
<body>
<form id="form1" runat="server">
<div id="buttonTarget">
</div>
</form>
</body>
</html>
If I run the following javascript a button is added to the page:
$('#buttonTarget').html('<asp:Button runat="server" ID="tst" CssClass="buttons" OnClick="Test" Text="Test"/>');
The buttons shows the same way as an asp tag shows in element inspector.
And when I click the button the server sided function is called and the site breaks with the "test" exception
I know this isn't good practice but I want to know why this works. Why does this button call the server sided function and why is it displayed as a normal button ?
--EDIT--
The aspx code was a simplified version. The actual code used a gridview control and used javascript to insert rows in the table. These rows hold the tags.
Expanding on what #Mamun was probably saying, when the page is executing on the server, it's seeing the asp tag in the JS string and translating it into the appropriate HTML. If you view source on your page in the browser, you'll probably see something like this instead of the ASP tag in your JS call:
$('#buttonTarget').html('<input type="submit" name="ctl00$MainContent$tst" value="Test" id="MainContent_tst" class="buttons" />');
I have some problems when i send the value variable in visual basic net to javascript, for example: this code:
Partial Class borrador1 // The code in aspx
Inherits System.Web.UI.Page
public myVariable As string
public sub MyMethod()
myVariable ="Hello World"
end sub
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
MyMethod()
end sub
In the next part i try to recive the value in javascript
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<script type="text/javascript">
var variable = '<%= myVariable%>';
</script>
<body>
</html>
I load the page and i see the next problem in the browser:
[HttpException (0x80004005): Please, see whether wrapping the code block, generating the exception, within RadCodeBlock resolves the error.]
Telerik.Web.UI.RadAjaxControl.MoveUpdatePanel(Control initiator, Control updated) +437
Telerik.Web.UI.RadAjaxControl.PerformRender() +419
Telerik.Web.UI.RadAjaxControl.OnPageRender(HtmlTextWriter writer, Control page) +1450
Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter writer, Control page) +197
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +131
System.Web.UI.Page.Render(HtmlTextWriter writer) +40
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5363
thanks for yours comments.
It seems that you need to register the script. Here is a link for your exact issue you are having. Happy coding!
Thanks my friend, but I resolve my problem. I use the controls telerik UI for ASP.NET AJAX, especific the charts, result the panel have a conflicts when i pass the variable, i comment the line (<%-- --%>) or write a function in jquery wait to load all the controls and when finish send the variable to javascript.
Could anyone tell me something helpful to the following behavior in JSF with Jscolor component?
I have got this simple xhtml code:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>RDFa test</title>
</h:head>
<h:body>
<script type="text/javascript" src="resources/js/jscolor/jscolor.js"/>
<h:form>
<h:commandButton class="color" value="ok"/>
<h:commandButton value="server" type="submit" action="#{testBean.tmp}"/>
</h:form>
</h:body>
</html>
TestBean.java:
#ManagedBean
#SessionScoped
public class TestBean implements Serializable {
public TestBean() {}
public void tmp() {
System.out.println("SERVER!");
}
}
If I do the first deployment and click on the "server" button, the Jscolor will go away and does not work (it is like destroying the javascript on the page)! If I then reload the page and click on the same button, the Jscolor works normally. There's no exception in server log, nor any error in Firebug JS console. How is this caused and how can I solve it?
EDIT:
I am not the only developer, who straggles with this issue. Here tyhand describes exactly, what I mean: http://www.tek-tips.com/viewthread.cfm?qid=1641380
COuld you please explain me what is happening and how to solve it?
Finally I found a solution. It is so easy!!! I have to add before all input fields with class='color' (binding fileds to the jscolor) this code:
<script>jscolor.init();</script>
I wanted to use jscolor inside a repeater that was inside an update panel in a custom DNN module.
None of the various solutions I saw here worked...I finally figured it out.
At top of HTML in your usercontrol:
Use <dnn:DNNJsInclude..... /> to point to your jscolor.js file, then add
<script type="text/javascript">
function pageLoad(sender, args) {
$(".jscolor").each(function (i, obj) {
var picker = new jscolor(obj);
});
};
On another forum someone complained that PageMethods are not defined. And someone provided an answer that said ... 'look, this is how you get them to work'. So I copied their code and tried it. I am still seeing PageMethods not defined.
The page looks like this:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="PageMethods.aspx.cs" Inherits="PageMethods" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body onload="GetFromServer();">
<form id="form1" runat="server">
<asp:ScriptManager runat="server" ID="ScriptManager1" EnablePageMethods="true"></asp:ScriptManager>
<div>
</div>
</form>
<script type="text/javascript">
function GetFromServer()
{
PageMethods.GetHello(OnGetHelloComplete);
}
function OnGetHelloComplete(result, userContext, methodName)
{
alert("Result: " + result + "\n" +
"Context: " + userContext + "\n" +
"Method name: " + methodName);
}
</script>
</body>
</html>
And this is the code behind.
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Services;
using System.Web.Script.Services;
public partial class PageMethods : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static string GetHello()
{
return "Hello From Server!";
}
}
When you run the page a javascript error occurs - 'PageMethods' is not defined.
This is a .net 2.0 web site.
I think this one will need .NET 3.5. I just used your exact code in a quick demo, and I was able to call the GetHello method without any trouble.
I'm having trouble getting my Javascript to run.
My javascript is located within the body tag of my master file (the layout page)
<script type="text/javascript">
var cssdropdown = {
startchrome2: function() {
document.getElementById("P3").innerHTML = "3 is complete";
}
}
</script>
I am attempting to call the startchrome2 function as follows:
<body onload="cssDropDown.startchrome2()">
The element I am attempting to access in my getElementById call is also located within the body:
<p id="P3">This is a paragraph.</p>
It is currently displaying "This is a paragraph". Why is my javascript failing to change it to "3 is complete"?
I've been fooling around with this for a while and it's quite frustrating. I'm sure it's a stupid error.
I am working in Visual Studio 2010 and the following are the declarations at the top of the page:
<%# Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs"
Inherits="SiteMaster" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit"
TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
Your casing is wrong, try:
<body onload="cssdropdown.startchrome2()">