If we want to parameterise SQL RAISERROR function we can easily do that as display below.
DECLARE @Msg VARCHAR(100)
SET @Msg = 'Number exceeded on ' +FORMAT (getdate(), 'dd/MM/yyyy')
RAISERROR (@Msg , 16, 1)
Cheers
Samitha
If we want to parameterise SQL RAISERROR function we can easily do that as display below.
DECLARE @Msg VARCHAR(100)
SET @Msg = 'Number exceeded on ' +FORMAT (getdate(), 'dd/MM/yyyy')
RAISERROR (@Msg , 16, 1)
Cheers
Samitha
We can use jQuery to show remaining character count for a RadEditor as shown below. This will wok for both design and HTML modes. Here MaxTextLength is considered as the upper character limit,
JS
var textLength;
var maxTextLength;
function radEditorOnClientLoad(editor, args) {
maxTextLength = editor.get_maxTextLength();
textLength = editor.get_text().length;
if (textLength > maxTextLength)
$('#charCountSpan' ).html("Characters Remaining: Limit Exceeded ");
else
$('#charCountSpan').html("Characters Remaining: " + (maxTextLength - textLength) );
$(editor.get_textArea()).on("input propertychange change keyup", ChangeCharacterCount);
$(editor.get_contentArea()).on("input propertychange change keyup", ChangeCharacterCount);
}
function ChangeCharacterCount( ) {
var editorElement = $find(<%= txtDetails.ClientID %>);
textLength = editorElement.get_text().length;
if (textLength > maxTextLength)
$('#charCountSpan').html("Characters Remaining: <span class='LimitExceed'>Limit Exceeded </span>");
else
$('#charCountSpan').html("Characters Remaining: " + numberWithCommas(maxTextLength - textLength));
}
HTML
<telerik:RadEditor ID="txtDetails" runat="server" TextMode="MultiLine" MaxTextLength ="2000" OnClientLoad="radEditorOnClientLoad" ></telerik:RadEditor>
<span id="charCountSpan" runat ="server" class="float-right"></span>
We can use jQuery to identify input text change as shown below. This method uses setTimeout and clearTimeout to force the change event fire only after user finishes typing.
JS
var timer;
$("#title").on("input", function(e) {
var textValue = $(this).val();
if ($(this).data("lastvalue") != textValue ) {
$(this).data("lastvalue", textValue );
clearTimeout(timer);
timer = setTimeout(function() {
//code to handle change
console.log(textValue);
}, 500);
};
});HTML<script src="jquery.min.js"></script>
<input type="text" id="title">Cheers
Samitha
We can use jQuery validate to format input URL with a valid URL as shown below
rules: {
url_field: {
required: true,
url: true,
normalizer: function (value){
value = value.replace(/^https?:\/\//, '');
return 'http://' + value;
}
}
}
Cheers
Samitha
If we want to dynamically add or change query string, URL API can be used as shown below
const url = new URL(location.href);
url.searchParams.set('queryStringKey', 'queryStringValue');
Cheers
Samitha
This is used for generating different HTTP codes. It can be useful for testing how scripts handle different responses.
Usage:
Add the status code to the URL,
Ex: httpstat.us/200
More information can be found here.
cheers
Samitha
http://jsonip.com is an free API which will return IP as a json response.
Response sample: {"ip":"192.100.200.10","about":"/about","Pro!":"http://getjsonip.com"}
Example
$.ajax({
type: "GET",
async: false,
url: "http://jsonip.com",
success: function (data) {
alert(data.ip);
}
});