DotNet Academy of Rajesh Rolen

Solutions by Rajesh Rolen

Set Cursor Position in TextBox.

If we want to set position of cursor to any character index in textbox by using following property:
TextBox1.SelectionStart= 2; //this will set cursor after 2nd character in textbox

Set Cursor Position in TextBox.

If we want to set position of cursor to any character index in textbox by using following property:
TextBox1.SelectionStart= 2; //this will set cursor after 2nd character in textbox

Make textbox numeric only with negative value accept

Lets we want to create a textbox which should take only numeric (double/decimal) value and the value can also be in negative
Solution:
Private Sub txt_KeyPressWithNegative(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtothercharges.KeyPress, txtfreight.KeyPress
Dim decexist As Boolean = False

If (CType(sender, TextBox).Text.IndexOf(".") > 0) And e.KeyChar.Equals("."c) Then
decexist = True
End If
If (e.KeyChar = "-") Then
If (CType(sender, TextBox).Text.StartsWith("-") = True) Then
e.Handled = True
Exit Sub
Else
e.Handled = True
CType(sender, TextBox).Text = "-" & CType(sender, TextBox).Text
CType(sender, TextBox).SelectionStart = CType(sender, TextBox).Text.Length
Exit Sub
End If
End If
If (Not Char.IsDigit(e.KeyChar) And Not Char.IsControl(e.KeyChar) And Not (e.KeyChar.Equals("."c))) Or decexist Then
e.Handled = True
End If
End Sub

Make textbox numeric only with negative value accept

Lets we want to create a textbox which should take only numeric (double/decimal) value and the value can also be in negative
Solution:
Private Sub txt_KeyPressWithNegative(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtothercharges.KeyPress, txtfreight.KeyPress
Dim decexist As Boolean = False

If (CType(sender, TextBox).Text.IndexOf(".") > 0) And e.KeyChar.Equals("."c) Then
decexist = True
End If
If (e.KeyChar = "-") Then
If (CType(sender, TextBox).Text.StartsWith("-") = True) Then
e.Handled = True
Exit Sub
Else
e.Handled = True
CType(sender, TextBox).Text = "-" & CType(sender, TextBox).Text
CType(sender, TextBox).SelectionStart = CType(sender, TextBox).Text.Length
Exit Sub
End If
End If
If (Not Char.IsDigit(e.KeyChar) And Not Char.IsControl(e.KeyChar) And Not (e.KeyChar.Equals("."c))) Or decexist Then
e.Handled = True
End If
End Sub

Difference between <%# Bind(””) %> and <%# Eval(””) %>

EVal is one way binding, Bind is two way

If you bind a value using Eval, it is like a read only. You can only view the data.

If you bind a value using Bind, and if you do some change on the value it will reflect on the database also

so when ever you just want to show metter on grid that time you should use Eval and if you want that user should be able to change the content and that should be reflect in database then we should use Bind

Conclusion:
Bind is Two way binding so data will go in both way from Database to Application and Application to Database.
Eval is One way binding so data will go in one way only, which is database to Application

Difference between <%# Bind(””) %> and <%# Eval(””) %>

EVal is one way binding, Bind is two way

If you bind a value using Eval, it is like a read only. You can only view the data.

If you bind a value using Bind, and if you do some change on the value it will reflect on the database also

so when ever you just want to show metter on grid that time you should use Eval and if you want that user should be able to change the content and that should be reflect in database then we should use Bind

Conclusion:
Bind is Two way binding so data will go in both way from Database to Application and Application to Database.
Eval is One way binding so data will go in one way only, which is database to Application

Difference between website project and webapplication project in VS2008

n the web**site** project, you typically work off a directory on your disk. There is no "project" file that defines the project's structure. Anything that's in that directory and any of its subdirectories automatically becomes part of your site - which can be a good or a bad thing.

A website project usually doesn't live inside a namespace, e.g. any code in your App_Code subdirectory will typically not have a namespace associated with it, which makes it sort of tricky and messy to use and reference from other places.

The web**application** project on the other hand is a real, true-blue project, complete with a project file and all. Anything that's in your project file will become part of your project - if you want to add something, you have to do so explicitly - it's not just automagically part of your project just because it's in your project directory. Again - this can be a good thing or a bad thing, depending on your style of development.

In my personal opinion, I would prefer the web application over the web site, mainly for the fact that I have more and more explicit control over what happens. A file doesn't just get added to my project (and potentially wreck havoc) just because it's lying around on disk. I have namespace and all - I have more control over what happens, when it happens

About this blog

My Blog List

Advertise On This Site

Site Info

Advertise on this Site

To advertise on this site please mail on RajeshRolen@gmail.com

Information Source

About

Pages

Dot Net Academy

Advertis in This Area of Site

Powered by Blogger.

Followers

Search This Blog