 |
|
|
 |
|
 |
Hello sir I have to display an Html file inside Iframe, the path of html file is given by browse File control of dotnet. it display an html file correctly when it exist in my project folder . but it does not display the file when user browse from any other location.. So how can I display the file into Iframe.. following is my javascript function function ShowPreview() { alert("file:///"+GetClientSideControl(document, 'FileUpload').value); document.getElementById('htmlPreviewIFrame').src = GetClientSideControl(document, 'FileUpload').value; // document.getElementById('htmlPreviewIFrame').src = "file:///"+GetClientSideControl(document, 'FileUpload').value; // tried also like this } please reply me soon sir..
|
|
|
|
 |
|
 |
hi,
im using ajax tabcontainer in which im using the iframes in order to create an html editor.It's working fine normaly but when im hosting the project through IIS its not displaying the the iframe content i.e.(src="temp.htm")
if i explicitly press refresh button then only its displaying it?
now how to handle this problem as this project is running very fine normally like a front page editor but when hosted its giving the problem.
thanks in advance!
naresh
|
|
|
|
 |
|
 |
Hello Sir,
The way you provide is one of the best way but whenever i'm sending the mail i'm receiving blank text or nothing.........
I'm putting my code here plz have a look and suggest me the problem exists in my code
I've already taken following controls.......given below
hidden Field= txtID
IFRAME = manojTextBox
-----------------------------------------------------------
Page_Load
if(!Page.IsPostBack)
{
cmdClick.Attributes.Add("onClick","document.Form1.txtID.value=manojTextBox.document.body.innerHTML");
}
-----------------------------------------------------------
Click Event
MailMessage mail1=new MailMessage();
mail1.To="mail@saamstesting.com";
mail1.From="manoj.manojbisht@gmail.com";
mail1.Subject="This is New Mail -2";
mail1.Priority=MailPriority.High;
mail1.BodyFormat=MailFormat.Html;
mail1.Body=Request.Form["txtID"];
try
{
SmtpMail.SmtpServer="mail.saamstesting.com";
SmtpMail.Send(mail1);
lblMsg.Text="Mail Sent Successfully";
lblMsg.ForeColor=Color.DarkBlue;
}
catch(Exception ex)
{
lblMsg.Text=ex.Message.ToString();
lblMsg.ForeColor=Color.Red;
}
|
|
|
|
 |
|
 |
pls tell me how work with C#
i can't use
<form id =frmMain method =post runat="server">
<asp:Label id=Label1 runat="server">Label<iframe
id=ifrHTML name=ifrHTML runat="server"></IFRAME><asp:button id=cmdSend runat="server" Text="Send"><input
type=hidden name=hidValue>
</form>
abc
|
|
|
|
 |
|
 |
That part you wrote, doesn't need to be changed to C#. That should work as it is.
The only thing that you need to convert is the Codebehind.
Inside the Page_Load
cmdSubmit.Attributes.Add("onClick", _
"document.frmMain.hidValue.value = ifrHTML.document.body.innerHTML;");
Inside the Click event
String strValue;
strValue = Request.Form["hidValue"];
I think that's all.
It's not why you're running, it's where your going
It's not what you're dreaming , but what you're going to do
It's not where you're born, it's where you belong
It's not how weak but what will make you strong
|
|
|
|
 |
|
 |
I have tried this and I can't get it to work for me. It only returns an empty html string.
I have tried to do it another way, by using this code:
<%
Response.Buffer = True
Dim objXMLHTTP, xml
' Create an xmlhttp object:
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
' Or, for version 3.0 of XMLHTTP, use:
' Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
' Opens the connection to the remote server.
xml.Open "GET", Request("target"), False
' Actually Sends the request and returns the data:
xml.Send
'Display the HTML both as HTML and as text
Response.Write "<xmp>"
Response.Write xml.responseText
Response.Write "</xmp>"
If Request("render") Then
Response.Write xml.responseText
End If
Set xml = Nothing%>
which returns the source of the iframe, I just have to download the url of the iframe separately, so I guess its not really getting it straight from the iFrame.
I would really like to figure out your solution, but I can't get it to work and I'm not sure what else to tell you, because I have checked everything and the code looks the same..I've just re-named it to get my iFrame!
|
|
|
|
 |
|
 |
This is supposed to be a very simple solution, you have an iframe, a hidden field, and a .NET web button. At page load you add javascript code, so when you click on the button, you get the html source code into the hidden field, and then on the server side you set the string to whatever the hidden field has.
About your other solution I can't really help you much there as I've never done it that way. But it could help if you posted the code that is not working for you based on this article.
Cheers
It's not why you're running, it's where your going
It's not what you're dreaming , but what you're going to do
It's not where you're born, it's where you belong
It's not how weak but what will make you strong
|
|
|
|
 |
|
 |
Here is the code.
Pretty sure it looks identical though..
<form id="frmMain" name="frmMain" method="post" runat="server">
<input type=hidden name=hidValue>
< asp : button id="cmdExtract" runat="server" Text="Extract Data From Page">
|
<IFRAME id="mlsFrameVis" style="WIDTH: 100%; HEIGHT: 100%" name="mlsFrame" c="iFrame.aspx">
</IFRAME>
|
</form>
<script>
//Set the IFRame to Desing Mode.
mlsFrameVis.document.designMode = "on";
</script>
THEN in the code behind:
private void Page_Load(object sender, System.EventArgs e)
{
cmdExtract.Attributes.Add("onClick","document.frmMain.hidValue.value =mlsFrame.document.body.innerHTML;");
}
private void cmdExtract_Click(object sender, System.EventArgs e)
{
string html = "";
html = Request.Form["hidValue"];
}
|
|
|
|
 |
|
 |
I think there's an error on your code on the page load while adding the attribute to the button you have mlsFrame, but it should say mlsFrameVis, as you specified it on the html.
Hope this helps.
It's not why you're running, it's where your going
It's not what you're dreaming , but what you're going to do
It's not where you're born, it's where you belong
It's not how weak but what will make you strong
|
|
|
|
 |
|
 |
ya.. sorry that was a cut/paste error. I had changed it halfway through and forgotten to take the Vis out of the page.
still doesn't work.
|
|
|
|
 |
|
 |
this is what is going on..which may affect it.
page loads with a Session variable which is the url of the iframe. when the iframe loads it redirects itself to the location of that session variable.
i noticed also on your code that you have a cmdSubmit button as well as a cmdSend button. is this intended? Or do i need an html (as opposed to an asp) button as well?
|
|
|
|
 |
|
 |
The session variable could be affecting it, but I wouldn't be sure. About the cmdSendB button, that was a typo in the aspx page should be cmdSubmit.
It's not why you're running, it's where your going
It's not what you're dreaming , but what you're going to do
It's not where you're born, it's where you belong
It's not how weak but what will make you strong
|
|
|
|
 |
|
 |
I tested the code myself and indeed it works, so I don't know what's going on. I tested in Win2k Pro SP4, VS.NET 2003 .NET Framework 1.1
It's not why you're running, it's where your going
It's not what you're dreaming , but what you're going to do
It's not where you're born, it's where you belong
It's not how weak but what will make you strong
|
|
|
|
 |
|
 |
weird. well do you know of another way of doing this?
one more thought I have.. my page is set in a subframe. all of this is happenening in the lower part of the main page. so one single top frame and one lower one. the cmdExtract is in the lower, and the iframe is in the lower.
|
|
|
|
 |
|
 |
alright. I even tried your exact code in a VB version and it doesn't work.
So there must be some kind of system setting. Service Pack 2 would be a nice cop out but if you know of anything else it'd be a great help. It must be some kind of security setting...know of anything?
Thanks.
|
|
|
|
 |
|
 |
Have you tried the same code without frames?
Service Pack 2, is that for Win XP?
It's not why you're running, it's where your going
It's not what you're dreaming , but what you're going to do
It's not where you're born, it's where you belong
It's not how weak but what will make you strong
|
|
|
|
 |
|
 |
yes, the VB version that I did had no frames. just the one iFrame. It didn't have any more code than your example has.
sp2 is the new service pack that tightened up security etc on sp2.
|
|
|
|
 |
|
 |
ahh..
sorry.. noticed one thing.
Says Access denied when I load the page that is JUST your code.
Line 23, char. 5. was using a variety of sites to test an dthey all had the same error.
I tried this on xp, and win2000
|
|
|
|
 |
|
 |
I really couldn't say what is going on. As I told you I tested in win2k and everything is fine. I'm really sorry that I can't provide any more help in this regard.
It's not why you're running, it's where your going
It's not what you're dreaming , but what you're going to do
It's not where you're born, it's where you belong
It's not how weak but what will make you strong
|
|
|
|
 |
|
 |
Ah, sorry.. I found the answer, unless you have ANOTHER workaround.
I can't access the innerhtml of the other form because it will potentially be from a different domain if the user browses off of my domain to another one.
Maybe there is a way to emulate the page in the iframe to be on the same domain?
|
|
|
|
 |
|
 |
I have tried using this but whenever anycode is bold, italicized, or underlined. The cmdSend_Click is not fired.
Has anyone been able to get this to work using Formatted text.
============
'CODE BEHIND
============
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
cmdSend.Attributes.Add("onClick", "document.frmMain.hidValue.value = ifrHTML.document.body.innerHTML;")
End If
End Sub
Private Sub cmdSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSend.Click
Try
Dim strValue As String
strValue = Request.Form("hidValue")
Catch ex As Exception
Throw New Exception(ex.ToString())
End Try
End Sub
=============
WEB FORM
=============
<HTML>
<body>
<form id=frmMain method=post runat="server">
<iframe id=ifrHTML name=ifrHTML runat="server"></iframe>
<asp:Button id=cmdSend runat="server" Text="Send">
<input type=hidden name=hidValue>
</form>
<script>
//Set the IFRame to Design Mode.
ifrHTML.document.designMode="on"
</script>
</body>
</HTML>
|
|
|
|
 |
|
 |
This was a great help so I could put data on a database using an IFrame as a kind of WYSIWYG html editor. Now I would like to know how I can put something on the IFrame so I can edit it?
Thanks
|
|
|
|
 |
|
 |
I'm not sure what you mean, but if you want to know how to make the IFrame editable, then it's right there in the code above.
But here it is anyway.
Just put the following
<script>
//Set the IFRame to Desing Mode.
ifrHTML.document.designMode = "on";
</script>
Where ifrHTML is the IFrame name and id
P.S. I'd appreciate if you'd rate the article
Cheers!
With great Project Management comes great Responsibility!!
|
|
|
|
 |
|
 |
First of all thanks for such a fast reply.
Well, let's if I can explain myself right, I've made a simple WYSIWYG editor using and editable IFRAME, I can pass the html from the IFRAME to a string following the steps provided in your article, so far so good, now imagine that I want to edit what I have on my string, I would have to pass my string to the InnerHtml...
Right now I have an hidden field named "html" on my form named "Form1" that as all that I want to put on the IFrame, I tried this without any result:
iView.document.body.innerHTML = Form1.html.value;
iView is the name of my IFrame.
Am I too far away from what I want to do?
|
|
|
|
 |