I have an HtmlEditor from asp controltoolkit.
That creates an iframe with a couple things i need (bold letter, etc).
I need to add text to that iframe with jquery.
so long i have this.
$('#<%= tbDescripcionInsert.ClientID %>').contents().text(textoMercancia.substring(15, textoMercancia.length));
My problem is that the things im using from the editor (bold letter etc) disappear when i add the text from jquery.
What can it be?
What is the best way to add text into an iframe with jquery?
Thank you very much.
If you want to handle markup, not just text, use html() instead of text().
the problem is that
.text('blahblah')
replaces the text so you must use
.append('blahblah')
or some similar command
EDIT
seeing your post this might be more effective
$('#<%= tbDescripcionInsert.ClientID %>').contents().find('body').append('blahblah')
Try something like:
var d = $("#someFrame")[0].contentWindow.document; // contentWindow works in IE7 and FF
d.open(); d.close(); // must open and
close document object to start using
it!
// now start doing normal jQuery:
$("body", d).append("ABC");
Thank you all for your help.
I found a way to solve this:
$('#<%= tbDescripcionInsert.ClientID %>_ctl02_ctl00').contents().children().children('body').html(textoMercancia.substring(15, textoMercancia.length));
this way i can access the exact part of the iframe where the information is supossed to be loaded.
hope this help someone in the future.
Related
I am new to ASP.NET. I made a simple application which performs some of the mathematical operation like addition, subtraction and so on. Now I have many Labels for each output(add, sub, multiply) . Now I want to display label(add output) first and then after 5 second I want to display next label and so on......
Can anyone help me out. Thanks.
First hide all the labels except 'ADD' using
$("#labelId").hide(); \\do this for all the labels except Add label
then
$("#labelAdd").delay(800).show(); \\give the delay as you like in milliseconds
$("#labelSub").delay(800).show();
$("#labelMul").delay(800).show();
Give a reference to jQuery library in head section then,
Put these scripts inside <script> tag inside
$(document).ready(function(){
//above code here.
});
You should definetly read some javascript or I would totally recommend jQuery, jQuery delay and jQuery show. Those are the 3 things you need.
You hide your label with some css visibility:hidden or display:none and then you can show it delayed with .show() from jQuery.
Have you done anything with javascript/jquery so far? need more help?
I'm trying to output the following HTML using Html.ActionLink:
Read More<span class="arrow">→</span>
I'm getting it done by doing an ActionLink, which outputs an <a> tag and then manipulating the string.
<%= Html.ActionLink("[[replace]]", "Index", "About", null, new { #class = "read-more" }).ToHtmlString().Replace("[[replace]]", "Read More" + "<span class='arrow'>→</span>")%></p>
It'd be good if I could put HTML directly into the ActionLink but there doesn't seem to be a way based on my internet searches. Sure, it works but it seems like a hack. Is there a better way to accomplish this?
Aaron...Did you work this out?
I use Url.Action in the href attribute when I need something other than just the link text in the outputted HTML.
Read More<span class="arrow">→</span>
Hope this helps.
Cheers,
-jc
You could write you're own HTML helper class and make it fit whatever needs you have. I've wrote a few before, I see the ones you get with MVC as just a start.
Here's a link with a tutorial. And here's and official MS video on how to.
If all you need is the arrow and you could use an image, you could use stylesheet to put that image after the link
.readmore-link{background-image: url('/image.png'); padding-right: 16px; /*...*/}
just tweak the image position etc.
Otherwise I'd recommend writing extension method for HtmlHelper.
Hai to all,
How can i give alert message with ok and cancel button within dataset function.if ok procced further else return in asp.net .......pls help
You can't show a client-sided message-box without using client-sided script.
It isn't possible. Both a standard browser alert window and a lightboxed one require JavaScript to display.
If you don't want to handcode the JavaScript, you can use the ASP.NET Ajaxtoolkit (http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ModalPopup/ModalPopup.aspx) which contains a ModelPopup control that handles it for you.
Add an "onclick" attribute to the object.
Page_load(){
object.Attributes.Add("onclick", "javascript:confirm('Are you sure')");
}
something like that.
You could use basic html to create a page that only has a small form in the centre of the page.
This would eliminate javascript.
I wonder why I can't get value from FCKEditor with this javascript? I work with asp.net so I know the controls get different names, mine is in a placeholder and in a usercontrol. How should I approach it to find the FCKEditor?
thx
function test()
{
var oEditor = FCKeditorAPI.GetInstance('FCKeditor1');
var pageValue = oEditor.GetHTML();
alert(pageValue);
}
This should work, but the problem is that using this approach you can not have this function in external JavaScript file. It has to be inline in your asp.net page.
function test()
{
var oEditor = FCKeditorAPI.GetInstance(<%= FCKeditor1.ClientID%>);
var pageValue = oEditor.GetHTML();
alert(pageValue);
}
FCKeditorAPI.GetInstance('<%=FCKeditor1.ClientID%>')
ASP.NET generates different IDs to the ones you use based on their position within the DOM. You should use the ClientID from within the client code to get at the actual ID, but without seeing the mark-up I can't tell for sure.
i tried this code an it work
FCKeditorAPI.GetInstance('ctl00_ContentPlaceHolder1_ctl00_FCKeditor1');
i tried
FCKeditorAPI.GetInstance('<%=FCKeditor1.ClientID%>')
thing that last wont work cause i got page - usercontrol - fckeditor
so the intellesence wont show the fckeditor. i would like to make it work with the last one
so i dont have to put the "ctl00_ContentPlaceHolder1_ctl00_FCKeditor1"
What is the best way to keep an asp:button from displaying it's URL on the status bar of the browser? The button is currently defines like this:
<asp:button id="btnFind"
runat="server"
Text="Find Info"
onclick="btnFind_Click">
</asp:button>
Update:
This appears to be specific to IE7, IE6 and FF do not show the URL in the status bar.
I use FF so never noticed this, but the link does in fact appear in the status bar in IE..
I dont think you can overwrite it :( I initially thought maybe setting the ToolTip (al la "title") property might do it.. Seems it does not..
Looking at the source, what appears is nowhere to be found, so I would say this is a browser issue, I don't think you can do anything in code.. :(
Update
Yeah, Looks like IE always posts whatever the form action is.. Can't see a way to override it, as yet..
Perhaps try explicitly setting it via JS?
Update II
Done some more Googleing. Don't think there really is a "nice" way of doing it.. Unless you remove the form all together and post data some other way..
Is it really worth that much? Generally this just tends to be the page name?
I don't see a link, I see this:
javascript:__doPostBack('btn','');
EDIT: Sorry, was looking at a LinkButton, not an ASP:Button. The ASP:Button shows the forms ACTION element like stated.
But, if you are trying to hide the DoPostBackCall, the only way to do that is to directly manipulate window.status with javascript. The downside is most browsers don't allow this anymore.
To do that, in your page_load add:
btnFind.Attributes.Add("onmouseover","window.status = '';");
btnFind.Attributes.Add("onmouseout","window.status = '';");