In this blog I will show how to use Join with Update command in SQL. I had a situation where I had to update the column of a table with the values from other table for all the employees simultaneously. There were 2 tables. a) Emp_Info table which contains a record of all employees like EmpID, EmpName, EmpAddress,EmpAge,TotalSalary. b) EmpSalary table which contains the salary for each mo...
In this blog i will explain you how to enable/disable textbox using jquery. <html xmlns="http://www.w3.org/1999/xhtml"> <head > <title></title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> </head> <body> <form id="form1" runat="server"> <div> <input id="txtName...
In this blog I'll explain you how to retain the values of dynamically created textboxes on Postback. Few days back, I had to create dynamic textboxes on a button click event. There was one more button on that page on which I'd to save the values of the textboxes which I entered in those dynamicaly created textboxes. But on clicking the that button values of dynamic textboxes were becomin...
Every one does search on google for code. At times we end up finding the code we were looking for but in some other languages such as VB.net, C++ etc. Now, that we have found the code but we want that code to be in some other language for ex C#. Someone who works in C# might not know about the syntax of VB.NET. So how to convert the code into the required language? As we all know that .N...
In this blog I will explain you how to change the value of a bit column . Recently, I had a scenario where I had to change the value of a bit type column i.e wherever there were 1 in the column I had to replace it with 0 and vice versa. After doing some searching I found the solution. I did it with the help of Common Table Expression (CTE). Let's create a table and insert few records int...
In this blog I'm going to explain how we can bind some rule to a Column of a table in SQL. Many times we want that the column must contain the value in a particular format. For Ex. Column Emp_ID should start with alphabet and after that it must contain 3 integers. Like 'A123' or 'E456'. This can be done in SQL by applying rules on the column. 1. Create a table CREATE TABLE EMP ( EMP_ID N...
In this blog we will see how we can validate the minimum length of textbox. <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>Validate Textbox</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> </head> <body > <form id="form1" runat="ser...
Once I was trying to access client script at .cs side by using ClientScript.RegisterStartupScript . But somehow it didn't work.After doing some research I found the solution to it.I realised that the reason why it wasn't working was because of update panel present on the page. ClientScript.RegisterStartupScript(typeof(System.String), "message", "<script> alert('I'm unable to access...
I tried to fix the maximum length in multiline textbox by using the property MaxLength. But it didn't work in case of multiline textbox. In this blog i will explain how to get rid of this problem by using jquery. $(function() { $('#ctl00_ContentPlaceHolder1_txtTest').keyup(function() { limitChars('ctl00_ContentPlaceHolder1_txtTest', 100, 'counter'); }) }); function limitChars(textid, lim...
Many times there can be a situation where we require the IP address of a user.For ex while placing an order on Shopping portal we need the IP address for security purposes.Below is the code of how to find users IP address in ASP.NET. public string FindIPAddress() { try { HttpRequest currentRequest = HttpContext.Current.Request; string ipAddress = currentRequest.ServerVariables["HTTP_X_FO...
Today I would like to share with you how to update,delete and edit rows in GridView data control.Gridview has most of the events inbuilt so one can use these events to perform these operations. 1.To edit a row in Gridview: To edit a row there is an event called RowEditing . protected void gridView_RowEditing(object sender, GridViewEditEventArgs e) { gridView.EditIndex = e.NewEditIndex; /...
Many times we face a situation where we want to delete multiple records from the Repeater.To delete multiple records from the repeater on button can be possible but to do so we need to add java script for checking/Unchecking multiple records.You need to add a javascript at page load for selecting multiple checkboxes together inside the repeater data control. Below is the way to do it.We ...
Recently i had faced a situation where i wanted to bind the values and names in the enum to the dropdownlist .After some research i found the way to do it. I'm sharing it with you guys.You can declare the enum like this : public enum Days { monday=1, tuesday, wednesday, thursday, friday, saturday, sunday } Now to bind the values and names to the dropdownlist i used Hashtable.As you all k...
I wanted the date format from SQL in this way January, 2008. After doing searching I finally found the way to do it. Here is the solution: SELECT DATENAME(month, DateCreated) AS ByMonth, DATENAME(yyyy, DateCreated) AS ByYear, COUNT(*) AS TotalCount FROM Test where userId=@UserID GROUP BY DATENAME(mm, DateCreated), DATENAME(yyyy, DateCreated) ORDER BY ByYear DESC The output will be in thi...
Sometimes there can be a situation where we want to validate maximum length of a textbox content.This can be done in many ways. One way of doing it is through Regular Expression: <asp:TextBox ID ="txtBox" runat="server"/> Now,take the Regular expression validation control <asp:RegularExpressionValidator ID="validateTextBox" runat="server" Display="dynamic" ControlToValidate="txt...
I was using modal pop up for both add and edit option on the same page. For this i used ModalPopupExtender of ajaxToolKit .But the problem which i faced was that when ever i clicked on the edit button.The pop up just came out but i didnt make any changes in the fields .So i clicked on the cancel button and the modal pop up just diappeared.The next time when i clicked on the add link the ...
Validate DropdwonList Hi Today im gonna tell you how to validate a dropdownlist Suppose if you want to validate a dropdownlist where you want that if the user doesnt select any value he/she should get an error message .This is how you can validate it. Her i want that user must select a country from the dropdownlist else he/she would get an error message Select a Country: <asp:DropDown...
Yesterday i was working on a registration page where if a person check the checkbox where the terms and conditions are written only then he/she can register .So i used a client side validation if a person doesn't select the checkbox then the alert box will appear where it is written that you must follow the terms and conditions. But on doing this the server side validations stopped worki...
It's fast, easy and free! Submit articles, get your own blog, ask questions & give answers in the forums, and become a better developer, faster.
enter your email address:
What kind of email newsletter would you prefer to receive from CodeAsp.Net?18