jquery ckeditor language dir - asp.net

how can i define the language dir in this code
$(document).ready(function () {
$('#Header1').ckeditor();
});

<script type="text/javascript" language="javascript">
$(document).ready(function () {
$('#<%=OrganizationMeta.vcr_MetaKey + Lang.int_LangId%>')
.ckeditor(function () { /* callback code */ }, { contentsLangDirection: '<%=TempData["Direction"] %>' });
});
</script>

Related

Replacing code with link to a file in ghost blog hbs

I am using the file_html function in bokeh to produce html that I want to embed into a ghost blog website.
If I load the id in a html card on the site, and then paste the head and body of the file into a code injection/header window, the output is fine.
But the html files can be long. So, rather than pasting the code, I want to save the file in my theme, and then include a link to that file. I've tried different ways, but can't get the chart to show.
This is what pasting the head/body into the code injection header looks like:
script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-2.4.3.min.js"></script>
<script type="text/javascript">
Bokeh.set_log_level("info");
</script>
<script type="application/json" id="1653">
{"1f335636-847c-44ca-ac3d-a39e52279a15":{"defs":[],"roots":{"references":[{"attributes":{"line_alpha":0.2,"line_color":"blue","x":{"field":"Date"},"y":{"field":"A"}},"id":"1474","type":"Line"},{"attributes":{"coordinates":null,"formatter":{"id":"1483"},"group":null,"major_label_policy":{"id":"1484"},"ticker":{"id":"1449"}},"id":"1448","type":"LinearAxis"},{"attributes":{},"id":"1483","type":"BasicTickFormatter"},{"attributes":{"coordinates":null,"formatter":{"id":"1480"},"group":null,"major_label_policy":{"id":"1481"},"ticker":{"id":"1453"}},"id":"1452","type":"LinearAxis"},{"attributes":{"data":{"A":{"__ndarray__":"q2jSD7sDvr+pDX3hPMntvxSFJEWY1eg/MVje9zOj8L+47dbtoFzTPw4XszUKu+0/","dtype":"float64","order":"little","shape":[6]},"B":{"__ndarray__":"1i8GC4Oi8D+uLg3FLEbsvwTnKftsKAPArl2CHJBq5L9l8duvR2/hPzi+J1DhqPA/","dtype":"float64","order":"little","shape":[6]},"C":{"__ndarray__":"hrXr9J6Xdr+t0s/xTnjKvxrjdAWjo/k/9U9XIzQq5D9rBurlogrxP0qoktgjAPg/","dtype":"float64","order":"little","shape":[6]},"D":{"__ndarray__":"s0qFVyjEtL+e/bFQtfTdv46B45hT4Mq/ftVSa9MK7b+DcTodgFj5P8Bs4A3NS/e/","dtype":"float64","order":"little","shape":[6]},"Date":{"__ndarray__":"AAAA57Nrd0IAAMBMBmx3QgAAgLJYbHdCAABAGKtsd0IAAAB+/Wx3QgAAwONPbXdC","dtype":"float64","order":"little","shape":[6]}},"selected":{"id":"1486"},"selection_policy":{"id":"1485"}},"id":"1437","type":"ColumnDataSource"},{"attributes":{},"id":"1440","type":"DataRange1d"},{"attributes":{"line_alpha":0.1,"line_color":"blue","x":{"field":"Date"},"y":{"field":"A"}},"id":"1473","type":"Line"},{"attributes":{},"id":"1484","type":"AllLabels"},{"attributes":{"coordinates":null,"data_source":{"id":"1437"},"glyph":{"id":"1491"},"group":null,"hover_glyph":null,"muted_glyph":{"id":"1493"},"nonselection_glyph":{"id":"1492"},"view":{"id":"1495"}},"id":"1494","type":"GlyphRenderer"},{"attributes":{},"id":"1459","type":"SaveTool"},{"attributes":{},"id":"1442","type":"DataRange1d"},{"attributes":{"line_color":"blue","x":{"field":"Date"},"y":{"field":"A"}},"id":"1472","type":"Line"},{"attributes":{},"id":"1453","type":"BasicTicker"},{"attributes":{},"id":"1457","type":"WheelZoomTool"},{"attributes":{"below":[{"id":"1448"}],"center":[{"id":"1451"},{"id":"1455"},{"id":"1488"}],"left":[{"id":"1452"}],"renderers":[{"id":"1475"},{"id":"1494"}],"title":{"id":"1470"},"toolbar":{"id":"1463"},"x_range":{"id":"1440"},"x_scale":{"id":"1444"},"y_range":{"id":"1442"},"y_scale":{"id":"1446"}},"id":"1439","subtype":"Figure","type":"Plot"},{"attributes":{"axis":{"id":"1452"},"coordinates":null,"dimension":1,"group":null,"ticker":null},"id":"1455","type":"Grid"},{"attributes":{"overlay":{"id":"1462"}},"id":"1458","type":"BoxZoomTool"},{"attributes":{"tools":[{"id":"1456"},{"id":"1457"},{"id":"1458"},{"id":"1459"},{"id":"1460"},{"id":"1461"},{"id":"1508"}]},"id":"1463","type":"Toolbar"},{"attributes":{},"id":"1485","type":"UnionRenderers"},{"attributes":{"source":{"id":"1437"}},"id":"1476","type":"CDSView"},{"attributes":{"label":{"value":"A"},"renderers":[{"id":"1475"}]},"id":"1489","type":"LegendItem"},{"attributes":{},"id":"1486","type":"Selection"},{"attributes":{"bottom_units":"screen","coordinates":null,"fill_alpha":0.5,"fill_color":"lightgrey","group":null,"left_units":"screen","level":"overlay","line_alpha":1.0,"line_color":"black","line_dash":[4,4],"line_width":2,"right_units":"screen","syncable":false,"top_units":"screen"},"id":"1462","type":"BoxAnnotation"},{"attributes":{},"id":"1456","type":"PanTool"},{"attributes":{},"id":"1446","type":"LinearScale"},{"attributes":{"coordinates":null,"group":null,"text":"Trial"},"id":"1470","type":"Title"},{"attributes":{},"id":"1480","type":"BasicTickFormatter"},{"attributes":{"coordinates":null,"group":null,"items":[{"id":"1489"},{"id":"1507"}]},"id":"1488","type":"Legend"},{"attributes":{},"id":"1444","type":"LinearScale"},{"attributes":{"line_alpha":0.2,"line_color":"green","x":{"field":"Date"},"y":{"field":"B"}},"id":"1493","type":"Line"},{"attributes":{},"id":"1460","type":"ResetTool"},{"attributes":{"callback":null,"formatters":{"#Date":"datetime"},"tooltips":[["Date","#Date{%F}"],["A","#{A}{0,0.0}"],["B","#{B}{0,0.0}"]]},"id":"1508","type":"HoverTool"},{"attributes":{},"id":"1461","type":"HelpTool"},{"attributes":{"line_alpha":0.1,"line_color":"green","x":{"field":"Date"},"y":{"field":"B"}},"id":"1492","type":"Line"},{"attributes":{},"id":"1449","type":"BasicTicker"},{"attributes":{"line_color":"green","x":{"field":"Date"},"y":{"field":"B"}},"id":"1491","type":"Line"},{"attributes":{"axis":{"id":"1448"},"coordinates":null,"group":null,"ticker":null},"id":"1451","type":"Grid"},{"attributes":{"source":{"id":"1437"}},"id":"1495","type":"CDSView"},{"attributes":{"label":{"value":"B"},"renderers":[{"id":"1494"}]},"id":"1507","type":"LegendItem"},{"attributes":{},"id":"1481","type":"AllLabels"},{"attributes":{"coordinates":null,"data_source":{"id":"1437"},"glyph":{"id":"1472"},"group":null,"hover_glyph":null,"muted_glyph":{"id":"1474"},"nonselection_glyph":{"id":"1473"},"view":{"id":"1476"}},"id":"1475","type":"GlyphRenderer"}],"root_ids":["1439"]},"title":"Bokeh Application","version":"2.4.3"}}
</script>
<script type="text/javascript">
(function() {
const fn = function() {
Bokeh.safely(function() {
(function(root) {
function embed_document(root) {
const docs_json = document.getElementById('1653').textContent;
const render_items = [{"docid":"1f335636-847c-44ca-ac3d-a39e52279a15","root_ids":["1439"],"roots":{"1439":"4484be71-5c42-4872-ad08-d14d68f5b8be"}}];
root.Bokeh.embed.embed_items(docs_json, render_items);
}
if (root.Bokeh !== undefined) {
embed_document(root);
} else {
let attempts = 0;
const timer = setInterval(function(root) {
if (root.Bokeh !== undefined) {
clearInterval(timer);
embed_document(root);
} else {
attempts++;
if (attempts > 100) {
clearInterval(timer);
console.log("Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing");
}
}
}, 10, root)
}
})(window);
});
};
if (document.readyState != "loading") fn();
else document.addEventListener("DOMContentLoaded", fn);
})();
</script>
And this is my latest attempt to replace the body with a link to the file:
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-2.4.3.min.js"></script>
<script type="text/javascript">
Bokeh.set_log_level("info");
</script>
<script type="text/html"
src="/assets/bokeh_new/s3_partial.html"
></script>

How to covert .cshtml to .aspx

I'm facing a problem when the same code at the .cshtml change to .aspx can't run in visual studio. How should I change any format or the coding for the run at .aspx? This a chatroom coding
#section scripts
{
<script src="~/Scripts/jquery.signalR-2.4.0.min.js"></script>
<script type="text/javascript" src="~/signalr/hubs"></script>
<script type="text/javascript">
$(function () {
var $chats = $('#chats'),
chatHub = $.connection.chatHub;
chatHub.client.gotMessage = function (nickname, message) {
$chats.append('<li><span class="label label-primary">' + htmlEncode(nickname)+'</span>' + htmlEncode(message));
$chats.scrollTop($chats.innerHeight());
};
var htmlEncode = function (content) {
return $('<div />').text(content).html();
}
$.connection.hub.start().done(function () {
$("#ctrl button").click(function (evt) {
var $name = $("#nickname"),
name = $name.val(),
$message = $("#message"),
message = $message.val();
chatHub.server.sendMessage(name, message);
$message.val("").focus();
});
});
$(window)
.resize(function () {
var h = Math.max(200, screen.availHeight - $chats.offset().top - 200);
$chats.height(h);
})
.resize();
});
</script>
}
There is no tag called section in ASP.NET webforms. So basically you could just remove the section tag.
In webforms you can use ContentPlaceholders like this, Masterpage:
<asp:ContentPlaceHolder id="scripts" runat="server">
</asp:ContentPlaceHolder>
And in any site using the masterpage:
<asp:Content ID="Content1" ContentPlaceHolderID="scripts" Runat="Server">
<script src="~/Scripts/jquery.signalR-2.4.0.min.js"></script>
<script type="text/javascript" src="~/signalr/hubs"></script>
<script type="text/javascript">
$(function () {
var $chats = $('#chats'),
chatHub = $.connection.chatHub;
chatHub.client.gotMessage = function (nickname, message) {
$chats.append('<li><span class="label label-primary">' + htmlEncode(nickname)+'</span>' + htmlEncode(message));
$chats.scrollTop($chats.innerHeight());
};
var htmlEncode = function (content) {
return $('<div />').text(content).html();
}
$.connection.hub.start().done(function () {
$("#ctrl button").click(function (evt) {
var $name = $("#nickname"),
name = $name.val(),
$message = $("#message"),
message = $message.val();
chatHub.server.sendMessage(name, message);
$message.val("").focus();
});
});
$(window)
.resize(function () {
var h = Math.max(200, screen.availHeight - $chats.offset().top - 200);
$chats.height(h);
})
.resize();
});
</script>
</asp:Content>

how to add section Scripts to asp.net mvc Razor View without layout page

My mvc view layout is null. how can i add script inside view.
#{
Layout = null;
}
#section Scripts{
<script type="text/javascript">
$(document).ready(function () {
$('#txtChild1').on('change', function () {
$("#C1Age1").show();
});
});
</script>
}
Error show
cannot resolve section 'Scripts'
If you use Layout = null then you don't need to use #section Scripts any more. you can simply use script tag.
Example:
#{
Layout = null;
}
<script type="text/javascript">
$(document).ready(function () {
$('#txtChild1').on('change', function () {
$("#C1Age1").show();
});
});
</script>
If you are not using layout page then you need not to add section. add scripts as you add them on a html page.
#{
Layout = null;
}
<script type="text/javascript">
$(document).ready(function () {
$('#txtChild1').on('change', function () {
$("#C1Age1").show();
});
});
</script>
You can also add script block without section if it is not mandatory.

button.Onclick event in asp.net

I am trying to do something like this:
<script type="text/javascript">
$(document).ready(function () {
$("#<%=InsertBtn.ClientID %>").click(function () {
var respond = confirm("Press ok if you confirm");
if (respond == true) {
this.onclick = true;
} else {
this.onclick = false
}
});
});
</script>
<asp:Button ID="InsertBtn" runat="server" Text="Insert" OnClick="InsertBtn_Click" />
how can I disable the onclick event when user response false?
well, i found an answer from internet,
<script type="text/javascript">
$(document).ready(function () {
$("#<%=InsertBtn.ClientID %>").click(function (e) {
var respond = confirm("Press ok if you confirm");
if (respond != true) {
e.preventDefault();
}
});
});
</script>
<asp:Button ID="InsertBtn" runat="server" Text="Insert" OnClick="InsertBtn_Click" />
by using the preventDefault() to cancel the onclick default action

jquery doesn't work after ajax auto refresh the updatepanel

<script>
!window.jQuery && document.write('<script src="jquery-1.4.3.min.js"><\/script>');
</script>
//this the jquery I'm using
<script type="text/javascript" src="jquery.fancybox-1.3.4.pack.js"></script>
<script type="text/javascript">
//the function calls the query
$(document).ready(function x() {
/*
* Examples - images
*/
//set the position of title on image
$("a#example7").imagebox({
'titlePosition': 'inside'
});
});
</script>
During Asynchronous page postback by updatepanels, $(document).ready function does n't get fired, so have to execute the code of $(document).ready in some other way.
you can execute any of these two ways:
1st way:
<script type="text/javascript">
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(InitializeRequest);
prm.add_endRequest(EndRequest);
function InitializeRequest(sender, args) {
//do any action that you want to be executed before postbacks
}
function EndRequest(sender, args) {
$("a#example7").imagebox({
'titlePosition': 'inside'
});
}
</script>
2nd way i.e. using RegisterStartupScript:
<script type="text/javascript">
function CreateImageBox() {
$("a#example7").imagebox({
'titlePosition': 'inside'
});
}
</script>
in c# code use:
ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanelTab.GetType(), "createimagebox", "CreateImageBox();", true);

Resources