Search This Blog

Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts

Thursday, July 9, 2015

link button property to open in new tab?

 By Adding following onClientClick even in your link button we can open the url in new tab.

OnClientClick="aspnetForm.target ='_blank';"

so on click it will call Javascript function an will open respective link in News tab.

<asp:LinkButton id="lbnkVidTtile1" OnClientClick="aspnetForm.target ='_blank';" runat="Server" Text="New Tab"  />

and another option is you can go for Hyper link control to achieve this. By default it has the Target property and you can set that to _blank.

thank you,

Monday, May 25, 2015

How to create a static variable at client side

Actually we cant create a static variable at client side. But we can keep the value even after page postback using Hidden field control.

First we need to create a hidden control and need to set ClientIDMode as "Static"

Ex: <asp:HiddenField ID="hndControl" ClientIDMode="Static" runat="server" />

After that we need to assign the value to that hidden field.

document.getElementById('<%= hndControl.ClientID %>').value = "Static";

Here after we can use that value until we change hidden field value.



Sunday, May 24, 2015

How to avoid alphabets and special character from text box using javascript

Use the following code OnKeyPress Event in your text box:

<asp:TextBox ID="txtNumber" runat="server" OnKeyPress="return IsNumeric(event);"></asp:TextBox>


function IsNumeric(e) {
    var keyCode = e.which ? e.which : e.keyCode
    var ret = ((keyCode >= 48 && keyCode <= 57) || specialKeys.indexOf(keyCode) != -1);
    document.getElementById("error").style.display = ret ? "none" : "inline";
    //TestOnTextChange();
    return ret;
}

Disable Copy, Cut and Paste options in text box

Include the following options in your text box:

onpaste="return false"
oncut="return false"
oncopy="return false"

it will avoid the cut, copy and paste options from your text box

Restricting Custom People Picker to only one Sharepoint group programatically

Refer the following script files in your page,     <!-- For People Picker -->     <script type="text/javascript" src...