Posts

Showing posts from 2016

validation city name from regex in javascript

Mostly this pattern used for US cities. It will be accept small and capital character, space, desh and full stop. if (/[^a-zA-Z .,]/.test(txtCity.value)) {           alert('Invalid city name');      } else {           alert('Valid city name');      }

Get all foreign keys reference in sql server

Solved: EXEC sp_fkeys 'TableName' its return to all foreign key reference to make that tables

scroll on top using jquery

Solved: $ ( 'html, body' ). animate ({ scrollTop : '0px' }, 300 ); you can set 0 instead of 300 its quickly go on top and you can change selector where you scroll means if you require scroll top to div just change selector and its working

Set span value using jquery and javascript

Solved: Jquery Example: you can set value two different function. 1- text(); 2- html(); $ ( "#submittername" ). text ( "testing" ); $ ( "#submittername" ). html ( "testing <b>1 2 3</b>" ); Difference between text and html functions text - you can set only value html - you can set value with html code but html tags not necessary for set the value JavaScript Example; you can set value from innerHTML document. getElementById ( "spanID" ).innerHTML. ( "testing" );

Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.

Solved:  When we use conditions on Eval many times we got the error, two ways use solve this error. 1- You make a function what you needs and bind before eval Example: bool ShowAge ( int age ) { return ( age > 18) ; } and call where you use eval Visible=' <% # ShowAge(Eval("Age")) %>' 2- You make a ItemCommand event and define condition on it protected void rptUser_ItemDataBound ( object source, RepeaterCommandEventArgs e ) { TextBox txtAge = ( TextBox )e.Item.FindControl("txtAge"); if ( DataBinder .Eval(e.Item.DataItem, "Age") > 18) { txtAge.Visible = false ; } ; }

how to insert text and tags at the cursor CKEDITOR

//change all "IDofEditor" to the id of your editor; I haven't figured out how to find it less explicitly //insert text CKEDITOR . instances . IDofEditor . insertText ( 'some text here' ); //insert a link (or other tags, modify as needed) //this example uses the selected text for the link text //if removing getSelection() and just inserting it all, you MUST have some link text or it will NOT insert; also if the user selected text first anyway it will change it to "NaN". //the \x22 represents a double quote, thus easy to use within an html onclick //getNative() gets the text, otherwise you get an object CKEDITOR . instances . IDofEditor . insertHtml ( '<a href=\x22my_link\x22>' + CKEDITOR . instances . IDofEditor . getSelection (). getNative () + '</a>' ); //you could also prompt the user for the link text (and title and link or anything else); very fast entry! CKEDITOR . instances . IDofEditor . insertHtml ( ...

float left or right from bootstrap predefined class

if you want to float left or right with Predefined classes of bootstrap Example:  HTML <div class="pull-left"></div> <div class="pull-right"></div> Asp.Net <asp:LinkButton ID="lnkCancel" CssClass="btn btn-primary pull-left" runat="server">Cancel</asp:LinkButton> <asp:LinkButton ID="lnkSave" CssClass="btn btn-primary pull-right" runat="server">Save</asp:LinkButton>

bind dropdownlist in repeater asp.net

Easy you set drop down list datasourse in repeater 1- Create ItemDataBound event 2- Check ListItemType one by one 3- Find dropdown which you take on repeater 4- DataSource protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)         {             try             {                 if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)                 {                     DropDownList ddl = (DropDownList)e.Item.FindControl("ddlAbc");                     DataTable dt = GetDataSource();                     ddl.DataSource = lstReferencePoint;                ...

Get Web API to return plain or simple text

Often we get as a collection or object when we test API and get return to a string like a plain text or auto generated ID. It is simple to view that code  response.Content.ReadAsStringAsync().Result

The tablix 'Tablix' is invalid. The value for the DataSetName property is missing.

The tablix is invalid. The value for the DataSetName property is missing. Solved: This is simply define any datasource field to rdlc report column.its cannot be empty without any passing dataset field.

Stop resizing textarea html

Disable textarea resizable functionality textarea {      resize: none; } You can also resize textarea horizontal or vertical. textarea {      resize: vertical; } textarea {      resize: horizontal; }

Required field validator trigger single button in one page in asp.net

Solved: Mostly user face the issue when use required field validator. Two asp.net button problem trigger one button for validate and another button for another performing but disturbed both button to show error, this problem has been solved to "ValidationGroup" just defined button and which controls to validate. Example: <asp:RequiredFieldValidator ValidationGroup='grp1' ... /> <asp:Button ValidationGroup='grp1' Text='trigger for validation' ... />

Inline if else condition in c#

Its mostly use assign only one variable or object Example : you have a variable and you want to check null value int a = 100 ; string result = string .Empty ; if ( a < 20 ) { result = "a variable less than 20" ; } else { result = "a variable not less than 20" ; } you can use instead of old condition because its a major benefit to reduce line of code int a = 100 ; string result = a < 20 ? "a variable less than 20" : "a variable not less than 20" ;

How to make script with data in sql

Image
Solved  Now we describe to step by step for easy to understand that how to make script with schema and data in SQL Server. 1- First you right click on desired database which you want to make script then select Tasks --> Generate Scripts... 2- Show new window for generating script click to Next button. 3- Select all object to specific database after click on Next button. 4- Click to Advance button show script advanced options ( Types of data to script ) option to select Schema and data then click to OK button. click to Next button on previous window. 5- This window for showing summary for generating script. 6- Finally successfully generate the script and you can click to Finish button.

How to remove query string in asp.net

Solved Request.QueryString.Remove("Parameter-Name") just run the program only this code it showing the read only error. use the below code 100% working PropertyInfo isreadonly typeof(System.Collections.Specialized.NameValueCollection).GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);             // make collection editable             isreadonly.SetValue(this.Request.QueryString, false, null);             // remove             this.Request.QueryString.Remove("Parameter-Name");

Edit code while application is debugging or run in visual studio

Go to debug tab --> Options and Settings --> Debugging --> Edit and Continue --> uncheck (Enable Edit and Continue)

Drop Down List item add in 0 index

ddlCategory.Items.Insert() have two overloads 1- define index,you can define value with item name by (ListItem) that is the simple code to add item of zero index in drop down list:     ddlCategory.Items.Insert(0, new ListItem("--Select Category--","0"));         ddlCategory.SelectedIndex = 0; 2- define index, only allowed to add item name like string

ConfigurationManager ConnectionStrings not available in c#

ConfigurationManager not show ConnectionStrings until you will not add reference System.Configuration dll, right click on Project -- Add Reference after click to Assemblies then Framework and find System.Configuration dll vs2010: Project -- Add Reference after click to .NET components and find System.Configuration dll If also add this reference but then again its not showing its a simple way to solve you add System.Configuration.ConfigurationManager.ConnectionStrings

Fatal error cygwin1.dll not found

Solved: The repository clone from source tree the following error occurred   cygwin1.dll missing errors or not found Reinstalling the source tree its fix this problem.

Find item in dropdownlist using jquery

var contain = false; $('#dropdownlist option').each(function(){     if (this.value == 'item-name') {         contain = true;         return false;     } });

Insert collection of data to sql table using c#

insert collection of data in SQL table is called bulk data manipulations, this is the simple and best way to add multiple row with the single collection now define a step's to easy to understand 1- You make a user defined table types  CREATE TYPE [dbo].[TTMultiRowCollection] AS TABLE(     [ID] [int] NULL,     [Name] [varchar(50)] NULL, ) 2- Create SP and take parameter table type as well as READONLY keyword. CREATE PROCEDURE [dbo].[AddMultiRow](@MultiRowCollection TTMultiRowCollection READONLY) AS BEGIN     INSERT INTO [User](ID,Name)         SELECT ID, Name FROM @MultiRowCollection END 3-  Create table in c# for passing the sql DataTable table = new DataTable(); table.Columns.Add("ID", typeof(int)); table.Columns.Add("Name", typeof(string)); table.Rows.Add(1, "Dawood"); table.Rows.Add(2, "Ahmed"); 4- Connect to SQL server and passing the table from stored procedure  us...

how to get last primary key in sql

Solved: If you want to get last primary key id instead of Max() aggregate function: IDENT_CURRENT('dbo.TableName') this is the best method to get last primary key id this is helpful for logic's

HTTP Error 500.19 Internal Server Error

The requested page cannot be accessed because the related configuration data for the page is invalid. Solved: Mostly 500 error occurred to three problems 1- Framework version not set according to the website 2- Permission the required folder 3- Directory not set to website where is located -- (cannot read configuration file)

How to use four clause in one query

Get records using with joins, where,group by, having and order by clauses FROM & JOINs determine & filter the selected rows WHERE more filters on the rows to desire columns GROUP BY combines those rows into groups like 1,1,1,2,2,3 result: 1,2,3 HAVING filters groups using to aggregate functions ORDER BY arranges the remaining rows/groups to order wise ascending or descending order

Get all rack according to shelf but books should not contain any position

select ri.RackID,ri.RackNo from RackInfo ri where ri.shelfID = 5 group by ri.RackID having (select Count(*) from fnGetPostionByRack(5,ri.RackNo,1)) > 0 so given some error any one can help me Column 'RackInfo.RackNo' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.