I use the Following script for change recaptcha in asp.net with c# server side.But this code Didn't Work.How to change color or theme of the ReCaptcha?
<script type="text/javascript">
var RecaptchaOptions = {theme : 'White'};
</script>
I think you are just writing the name of the theme in wrong way, just try White with a small 'w'.
<script type="text/javascript">
var RecaptchaOptions = {theme : 'white'};
</script>
See this link for exact working code:
https://developers.google.com/recaptcha/docs/customization
George Siggouroglou's second method for asp.net is a charm
I couldn't seem to set the theme as instructed in https://developers.google.com/recaptcha/docs/customization - placed the js above the form containing the recaptcha control - but adding the theme attribute directly into the recaptcha code as George explained:
<recaptcha:RecaptchaControl
ID="recaptcha"
runat="server"
PublicKey="your-public-key"
PrivateKey="your-private-key"
Theme="white"
/>
works.
U used the capital W instead of small i.e. w
Try this
Change the theme and try
<script type="text/javascript">
var RecaptchaOptions = {
theme : 'white'
/*WE CAN USE FOLLOWING THEME TO CHANGE THE COLOR OF RECAPTHCA*/
/*red,white,blackglass,clean'*/
/*lang :'es';*/ //used to set the language
};
</script>
If you are using asp.net and if you are using the recapctcha for asp.net control, then if you want to change the theme (red(default),white,blackglass,clean) there is two ways.
Way no1,
To make the reCAPTCHA widget display a different theme, you first need to add the following
code in your main HTML page anywhere before the element where reCAPTCHA appears
(this will not work if placed after the main script where reCAPTCHA is first invoked):
<script type="text/javascript">
var RecaptchaOptions = {
theme : 'theme_name'
};
</script>
Way no2:
Add the property 'Theme' to the recapcha asp.net control:
<recaptcha:RecaptchaControl
ID="recaptcha"
runat="server"
PublicKey="your-public-key"
PrivateKey="your-private-key"
Theme="white"
/>
Related
I am currently trying to make a input tag display a calendar with jquery on an ASP.net MVC. I am not sure if i am linking it correctly as I am new to MVC's.
The input tag i am using for the datetimepicker:
<input class="minDate" id="minDate"/>
the script inside the page along with the link of the datetimepicker from this site
#section Scripts
{
<script type="text/javascript">
$(function () {
$('#minDate').appendDtpicker({
"inline": true,
"futureOnly": true
});
});
</script>
<script src="/Scripts/jquery.simple-dtpicker.js" type="text/javascript"></script>
}
From the example of the site, the calendar should appear on clicking the input box. But sadly nothing appears.
I want to know if i have linked the JS wrong? Do i need to use getScript instead of a script tag? and If that is fine am i calling it wrong?
Thank you in advance.
You have to ask for the library before using it.
There are many similar questions already, but for some reason they do not solve my issue.
My project is to save a dynamically created page (or part of the page). The user will have the option to drag objects on screen and leave them in any order and then for this order to be saved to disc as an image.
My own research shows that I can use Draggable from JQuery and this is easy to implement. It is the saving part where I am stuck.
I followed a few links, but the image does not appear to be saving to disc and I don't think it works in IE! However, I'm happy with FireFox and so using the toDataUrl() sounds like the best approach.
Since I couldn't get it work I decided to change tactic slightly and pass the value to the code behind (C#)
The save part of my code looks like
<script>
function SaveMe() {
var canvas = document.getElementById("mycanvas");
var image = canvas.toDataUrl();
document.getElementById("hideMe").value = image;
}
</script>
When I debug in FireBug, I never reach document.getElementById("hideMe").value = image;. I step through but can never get past var image = canvas.toDataUrl(); Is this expected behavior as I assume not but there is no error message?
The body of my HTML is
<body>
<script type="text/javascript">
$(document).ready(function () {
$('.popup_click').show(0).draggable();
});
</script>
<form id="form1" runat="server">
<div class="popup_click">
<div id="popup_title">Title</div>
</div>
<canvas id="mycanvas" class="canvas"></canvas>
<asp:HiddenField ID="hideMe" runat="server" />
<asp:Button runat="server" OnClick="ClickMe" text="Click" OnClientClick="SaveMe()"/>
</form>
</body>
What am I doing wrong? I'm working locally in debug mode, Visual Studio 2013.
Not absolutely sure, but I also had a problem with todataurl() in the past and this link helped me
Not able to get data url when using images in kinetic js
This is the function I always use when wanting to export a canvas to image, it puts the image into a popup window so the user can do what they want with it (I hope this helps):
function imageCanvas(evt){
var imageCanvas = document.createElement('canvas');
imageCanvas.width = document.documentElement.clientWidth;
imageCanvas.height = document.documentElement.clientHeight;
var imageCanvasContext = imageCanvas.getContext("2d");
imageCanvasContext.fillStyle = document.getElementById("body").style.backgroundColor;
imageCanvasContext.fillRect(0,0,imageCanvas.width,imageCanvas.height);
imageCanvasContext.drawImage(mainCanvas,0,0,imageCanvas.width,imageCanvas.height,0,0,imageCanvas.width,imageCanvas.height);
var dataURL = imageCanvas.toDataURL("image/png");
var imagePopup = window.open("","fractalLineImage","left=0,top=0,width="+(imageCanvas.width/2)+",height="+(imageCanvas.height/2)+",toolbar=0,resizable=0");
imagePopup.document.write("<title>Export Image</title>");
imagePopup.document.write("<img id='exportImage'"
+" alt=''"
+" height='"+ imageCanvas.height+"'"
+" width='"+ imageCanvas.width+"'"
+" style='position:absolute;left:0;top:0'/>");
imagePopup.document.close();
var exportImage = imagePopup.document.getElementById("exportImage");
exportImage.src = dataURL;
}
if i'm showing the user search results in a page is there any jquery plugin or some c# code for summarizing the text based on the keywords user searched for ?
for example if the text is :
some very very very [ some words here ] very very very long text
and the user is searching for "words" it should turn into :
... very [ some **words** here ] very ...
In ASP.NET you can use <summary> tag by applying your own logic as per your requirement.
Refer following link for this:
http://msdn.microsoft.com/en-us/library/2d6dt3kf.aspx
Or
With external tools like extractor.
It can be also done with Jquery as follows:
<script src="jquery.js" type="text/javascript"></script>
<script src="jquery.summarize.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
// simple example, using all default options
/***** apply the summarize() method to the "containing" element ****/
$('div.expandable').summarize();
});
</script>
For this you will have to download Jquery Plugin.
Hope Its helpful.
I have a situation. I am using web application of windows(ASP.NET). On page load when my web page appears, it has dynamically generated ImageButtons. I need to fid the X,Y or TOP,LEFT co-ordinates of each ImageButton control on the page WITHOUT CLICKING ON ANY OF THE ImageButtons.. I need to draw a line beetween some ImageButtons on the click of one ImageButton.
Try using some Javascript code or jQuery. Please find below jQuery code
Here i have used position() method which gives you left and top position of the element. You can change the selector based on your need.
Update: Assumed you have HTML like <div id='images-container'> .. all images here </div> and updated selector below for that with each() method
You can also use offset()
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$('#images-container img').each(funcion(){
var coordinates=$(this).position();
coordinates.left;// gives you x
coordinates.top;// gives you y
//save these values in some hidden field and access it in code behind if needed
});
});
</script>
Please refer this post for more information jQuery x y document coordinates of DOM object
well. The problem i'm facing is i have my own custom control and i do a query , get records and dynamically add html controls to the page based on the data.
Now there's the problem of adding some dynamic javascript
I do this with the help of literal controls.
<asp:Literal runat="server" ID="latEventToolTipJqueryScripts"></asp:Literal>
This works like a charm
<script language="javascript" type="text/javascript">
// <![CDATA[
Sys.Application.add_load(WireEvents_<%=this.ID%>); // fix wiring for .NET ajax updatepanel
$(WireEvents_<%=this.ID%>); // handle page load wiring
function WireEvents_<%=this.ID%>() {
<asp:Literal runat="server" ID="latEventToolTipJqueryScripts"></asp:Literal>
}
// ]]>
</script>
I add the literal text dynamically from code behind.
However, when placing the control in an updatepanel, the postbacks don't update the script.
EDIT: The Sys.Application.add_load rewires the necessary functions just fine with the updatepanel. The problem is that the script that needs to be in place of the literal, doesn't update when in an updatepanel.
I've tried the ClientScript.RegisterStartupScript but it has the same effect as with the literal control trick. Any help?
---------------------------SOLVED (tnx to Pranay Rana)----------------------------------
Got rid of the literal in the ascx side. as well as the Sys.Application.add_load
now it's only in the code behind. The thing that was throwing me off was the JQuery thing.
this.strBuilderJS.Append( "<script language='javascript' type='text/javascript'>" +
"$(WireEvents_" + this.ID + ");" +
"function WireEvents_" + this.ID + "(){"+
" alert('stuff');");
this.strBuilderJS.Append( "}</script>");
and then
ScriptManager.RegisterStartupScript(this, this.GetType(), "strBuilderJS", strBuilderJS.ToString(), false);
Make use of ScriptManager.RegisterStartupScript() to register your script...may resolve problem ...
Check this resolve your problem : Add JavaScript programmatically using RegisterStartupScript during an Asynchronous postback
I would recommend on a different approach. To create a dynamic javascript for any language. I would create a reference to a dynamic file. For this example I will use .NET
Create a test.aspx page and add this script:
<script type="text/javscript" src="js/foo.aspx"></script>
Make sure your page response with the right content type. So for this instance I would add this on page load code behind for your foo.aspx:
Response.ContentType = "application/javascript";
On the foo.aspx html view add your javascript code.
alert("<%=DateTime.Now%>");
Browse your test.aspx page and you should see an alert with the current date
You should be able to move forward from here. The goal is to separate the javascript file from the static page.
Happy Coding.
How to change text of ASP Button control on anchor tag click
We have an ASP Button below and we want to change text when WE click on anchor tag
<asp:Button ID="btn_Add" runat="server" CssClass="button2" onclick="btn_Add_Click"/>
We have following two anchor tags
Add New
Add New
Now we add following code in script tag
<script type="text/javascript" language="javascript">
function changeText1() {
document.getElementById("lbl_header").innerText = 'Add New Teacher';
document.getElementById("btn_Add").value = 'Add';
}
</script>
<script type="text/javascript" language="javascript">
function changeText2() {
document.getElementById("lbl_header").innerText = 'Delete Teacher';
document.getElementById("btn_Add").value = 'Delete';
}
</script>