Posts

Compare DataColumn to null

Hello all, Today i got struck in a way how to compare a null value which is coming from database in a dataset........  tried few ways, like this                                  Object.Equal(ds.Tables[0].Rows[0]["date],null)              ds.Tables[0].Rows[0]["date] == null              Object.ReferenceEquals(ds.Tables[0].Rows[0]["date],null) but nothing worked ...... at last after a cup of Cappuccino something clicked me & made me feel how stupid my thinking was because this is DBNull type & I  am trying to compare with a different object …….. so finally it worked like this               value.Equals(System.DBNull.Value) Hope this helps someone J

Get Text Height & Width

In many cases we tend to work with dynamic data transaction & data formatting, then we maty need to calculate the width, height & align accordingly w.r.t  specific  font details etc.,,,,, I got in to same scenarios, where i need to brush the text on a image & i was breaking my head how to calculated the starting point w.r.t text size, font   etc.,,,,,,,,,, after a long of R & D ; got something which saved me i.e., Graphics class (which is a dotnet inbuilt class) Usage : Creating a instance Graphics   grpControl = CreateGraphics(); Creating a dummy string value String   minstr =”Minimumvalue”; Font details I will be working with Font   textFont   =   new   Font ( "Arial" , 16,   GraphicsUnit .Pixel); Now the destination of calculation, graphics Class has a method named MeasureString this is return value of type    SizeF SizeF: It stores the floated points SizeF   sizeDetails = grpControl.MeasureString(minStr,textFont); Now the r

Maximize child MDI form without ControlBox

Problem: When we try maxing the form as maximum mode using control box buttons , then every thing goes fine and it be maximized and can see the toolbar below. But when we try doing the same with with controlbox = false( this will hide the control box), now if you try making the for to maximize, it will be maximized but it will also hide the toolbar below. When we hide the control box the form will be maximize to the whole screen ( hiding the system toolbar). Solution: Hide the control box on page Code : Please paste this code in form load method In VB Me.ControlBox = False In C# this.ControlBox = false;

Adding text to label using javascript

While accessing label value from JavaScript, we try like this document.getElementById('<%= this.lblClientType.ClientID %>').value But this wont work as it doesn't contain a property called value. Resolution : document.getElementById('<%= this.lblClientType.ClientID %>').innerHTML Reason: Because when we see the page source, label is been converted to span, where as textbox is converted to input control asp:label to span control asp:textbox to input of type "text" Please provide the comments, if any...

Changing the textbox color dynamically

Changing the text box styling dynamically using java script. < script > function txtBr(Recid) { if(Recid==0)document.getElementById ("Text1").style.border ='0px'; if(Recid==1)document.getElementById ("Text1").style.border ='1px'; if(Recid==1)document.getElementById ("Text1").style.borderStyle='solid'; if(Recid==1)document.getElementById ("Text1").style.borderColor ='red'; if(Recid==1)document.getElementById ("Text1").style.backgroundColor='yellow'; if(Recid==1)document.getElementById ("Text1").focus(); } < /script > < /head > < body onload ="txtBr(0);" > < form id="form1" runat="server" > < input id="Text1" type="text" runat ="Server" onmousemove ="txtBr(1);" / >

Dynamically creation of web controls and binding Validations Using ASP.NET

Image
Dynamically creation of web controls and binding Validations Using ASP.NET Source Code : creatingdynamiccontrols2.zip Introduction:- As we know we can bind the controls to our page (aspx) in 2 ways 1. Statically :- Binding the controls while Designing 2. Dynamically :- Binding the controls at runtime Everyone know how to bind statically but there may be some cases where we need to bind the control dynamically .One of those cases is when our controls are keep on changing like I have a registration site in which the control type may keep on changing then I may need to go for binding the controls dynamically . Approach: For binding the controls I need the data what are the controls I want to bind and what is the id to be given and what are the properties to be provided etc., This can be provided by 2 ways 1. Using database (This is my approach) 2. Using Xml file I am creating one example (registration Page) where I am getting the data from the database as a table and ba

Association, Aggregation, Composition

Association, Aggregation, Composition When we have only one relationship between objects that may be Association . Aggregation and Composition.             In details             Association :             This is relation where each object has it own life cycle , independent  and no owner. Ex:-             Will take a common example of project and developer             A project will be having multiple developers and developer can work for different projects. There is a relationship but both are independent. Both can create and delete independently.   Aggregation: This is a specialize form of Association where all object have their own lifecycle has ownership on child object and the child object cannot belongs be related to another parent object. Ex:-             Will take an example of Departments and developers             A developer can be only in one department like dotnet, java etc., but if we delete the Department object still the Developer object exists. This is a “Has-