Message Filter:
Message filter to prevent specific events from being raised to the control or Forms.
We can achieve the Message Filter through IMessageFilter Interface. It has overridable method name PreMessageFilter.Using this method we can customize our Message Filters.
Example : Filter/Restrict left mouse button down message
public class MyMsgFilter : IMessageFilter
{
public bool PreFilterMessage(ref Message m)
{
// Filter/Restrict left mouse button down message.
if (m.Msg == 513)
{
return true;
}
return false;
}
}
In order to monitor the Message Filter in our application you must register Filter class in your application.
public class mainForm : System.Windows.Forms.Form
{
private MyMsgFilter msgFilter = new MyMsgFilter();
public mainForm()
{
// Add message filter.
Application.AddMessageFilter(msgFilter);
}
}
Following way you can remove your Message Filter
Application.RemoveMessageFilter(msgFilter);
JavaScript document.getElementById
If you want to quickly access the value of an HTML input give it an id to make your life a lot easier.
This small script below will check to see if there is any text in the text field "myText". The argument that getElementById requires is the id of the HTML element you wish to utilize
This small script below will check to see if there is any text in the text field "myText". The argument that getElementById requires is the id of the HTML element you wish to utilize
<script defer="defer" type="text/javascript">
function notEmpty()
{
var myTextField = document.getElementById('myText');
if(myTextField.value != "")
alert("You entered: " + myTextField.value)
else
alert("Would you please enter some text?")
}
</script>
<input type='text' id='myText' />
<input type='button' onclick='notEmpty()' value='Form Checker' />
Labels:
ASP.NET,
HTML,
JavaScript,
JavaScript-getElementById
Difference between Abstraction and Encapsulation
Abstraction:
It is virtual class design.
Representation of data that how we represent it.
Before actually defining class developer will think about about the properties, methods and events will be there in class.
Encapsulation:
Hiding of unnecessary data.
At the time of class definition developers will think about which should display to end user and which should not.
Conclusion:
Abstraction is collection of data and Encapsulation is exposure of data in appropriate access specifier.
It is virtual class design.
Representation of data that how we represent it.
Before actually defining class developer will think about about the properties, methods and events will be there in class.
Encapsulation:
Hiding of unnecessary data.
At the time of class definition developers will think about which should display to end user and which should not.
Conclusion:
Abstraction is collection of data and Encapsulation is exposure of data in appropriate access specifier.
Labels:
OOPS
Difference between Rule and Check Constraint
Check Constraint:
Check constraint is associated with columns in a Table. So these can't be re-used.
Suppose if "Emp" table having the coulmn "Salary" then
alter table Emp add constraint ck_op Check (Salary between 15000 and 45000)
Rule:
Rules are defined with in a database and can be applied to any number of columns.
Creating Rule:
CREATE RULE SAL_RANGE
as
@Sal > 15000 and @Sal > 45000
Binding Rule to a Column:
SP_BINDRULE 'SAL_RANGE','Emp.Salary'
Check constraint is associated with columns in a Table. So these can't be re-used.
Suppose if "Emp" table having the coulmn "Salary" then
alter table Emp add constraint ck_op Check (Salary between 15000 and 45000)
Rule:
Rules are defined with in a database and can be applied to any number of columns.
Creating Rule:
CREATE RULE SAL_RANGE
as
@Sal > 15000 and @Sal > 45000
Binding Rule to a Column:
SP_BINDRULE 'SAL_RANGE','Emp.Salary'
Labels:
SQL SERVER
Encapsulation
When designing a class, it is generally a good practice to only reveal the necessary interfaces needed to interact with the object, and hide the implementation details that are not precisely relevant. This hiding of details is known as encapsulation.
The concept of encapsulation is better enforced with the definitions of interfaces and implementations. An interface is defined by the services of communication between objects. Classes declare some methods and properties as visible to outside objects, and hide the other details. The visible, or public, methods and properties become the interface to the object. Interfaces typically only include methods, since any need to access an attribute should be made available through a public method.
public class ClsEncapsulation
{
int SqrOutput;
public ClsEncapsulation()
{
}
//Visible method
public void AssignNumber(int GivenNumber)
{
CalculateSqluare(GivenNumber);
}
public void Display()
{
Console.WriteLine("Square of given number is " + SqrOutput.ToString());
}
//Hiding Method
private void CalculateSqluare(int GnNumber)
{
SqrOutput = System.Math.Pow(GnNumber,2);
}
}
The concept of encapsulation is better enforced with the definitions of interfaces and implementations. An interface is defined by the services of communication between objects. Classes declare some methods and properties as visible to outside objects, and hide the other details. The visible, or public, methods and properties become the interface to the object. Interfaces typically only include methods, since any need to access an attribute should be made available through a public method.
public class ClsEncapsulation
{
int SqrOutput;
public ClsEncapsulation()
{
}
//Visible method
public void AssignNumber(int GivenNumber)
{
CalculateSqluare(GivenNumber);
}
public void Display()
{
Console.WriteLine("Square of given number is " + SqrOutput.ToString());
}
//Hiding Method
private void CalculateSqluare(int GnNumber)
{
SqrOutput = System.Math.Pow(GnNumber,2);
}
}
Subscribe to:
Posts (Atom)