hi friend
you can use Filter Textbox extender to avoid spaces in Textbox check by below code
To use this Don't forget to use its .Dll File i.e. Ajax .dllfile of version same to the .Net Framework its directive that you will use with your master page or directly you can use in webpage
<asp:filtertextboxextender id="FT_Removespaces" runat="server" setfocusonerror="true" filtertype="Numbers,Consonants,LowerCase,UpperCase" filtermode="" display="Dynamic" xmlns:asp="#unknown"></asp:filtertextboxextender>