JavaScript Alert Message Before Page Redirect

We can alert JavaScript message before redirect to any page by below script

 


string Message = "Your message here.";
string url = "Login.aspx";

Response.Write(@"<script language='javascript'>alert('" + Message + "');document.location.href='" + url + "'; </script>");

 

SQL Server Table Recreation Issue

While working with SQL Server we may get below error :

Saving changes is not permitted. The changes you have made require that the following tables to dropped and recreate.
You have either made changes to the table that can’t be recreate or enable the option prevent saving changes that require the tables to be recreate.

We can disable above error message by SQL Server Environment settings

Follow below steps to configure SQL Server environment

Log in to SSMS

Navigate to

Tools – Options – Designers

Select Check box – Prevent saving changes that require the table re-creation

This option will help you in above error.

SQL Server Settings

ASP.Net How to show multiple validation group on Submit Button (Single Button)

Its little bit complex to show different validation group on signle Submit button click validation

To achieve this or show all validation (which has different validation group ) check below code

Page contains 3 validation groups

1. mailvalidation — Validation for Email Address
2. Uasenamevalidation — Check Username and validation
3. Page — All other Control Validation Group

ASP.Net Button Syntax:

<asp:Button ID="btnSave" runat="server" Text="Submit" OnClientClick="return Validate()" /></pre>

JavaScript Code :


<script type="text/javascript">
function Validate() {
var isEmailValidation = Page_ClientValidate("mailvalidation");
var isUserNameValidation = Page_ClientValidate('Uasenamevalidation');
var isControls = Page_ClientValidate("Page");

if (isEmailValidation && isUserNameValidation && isControls)
return true;
else
var i;
for (i = 0; i < Page_Validators.length; i++) {
ValidatorValidate(Page_Validators[i]); //this forces validation in all groups
}
return false;
}
</script>

In above script Else part forces validation of all groups which are remaining and will show message.

SharePoint How to make an Application Page Anonymous

To make application Page as Anonymous inherit it by : Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase

ie. in C# Code

public class ApplicationPage : Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase

Also add below dunction in Code

protected override bool AllowAnonymousAccess
{
get
{
return true;
}
}
Page Code Sample :

public partial class ApplicationPage : Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase
{

protected override bool AllowAnonymousAccess
{
get { return true; }
}

Jquery Add Href attribute to Link

To append Href attribute in existing link follow below Jquery

Link :

<a class=”hclass” ><img src=”/images/link.png” id=”htest” border=”0″ alt=””/>Google</a>

Jquery Script :

<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js”></script&gt;
<script>
$(document).ready(function(){

$(‘#htest’).attr(‘href’,’https://www.google.co.in/&#8217;);

});
</script>