Skip to main content

Posts

How to get the readonly textbox value on the server

In ASP.NET 2.0 and Newer versions , the readonly TextBox will ignore the submitted text , this change due to security reasons . However , assume you have a readonly textbox and you are going to change its value on the client side ( via script) , Now how you will get the changed value on the server side ? One option is to disable the textbox control , and set "SubmitDisabledControls" for the form to true , but this is not always a solution . For example you want to use the Calendar extendar with the textbox and you don't want to let the user to change the textbox manually , instead you want to let the user select the date via the calendar extendar. now the problem is that the selected date will not be accepted by the textbox when the user submit the form , because the textbox is in readonly mode , in this case you need to manually set the submitted textbox value , you can easily use the values that is submitted via form collection , something like this: Pr...

UserControls

User Control: User Control is the custom, reusable controls. User Controls offers a way to partition and reuse User Interface (UI) functionality across ASP.NET Applications. Advantages of User Control: • Code Reuse. • Cache the output of the control independently using technique called fragment caching. This will improve performance if used appropriately. • Can program against any properties declared in the control, just like ASP.NET web controls. Disadvantages of User Control: • User Controls can be instantiated in the pages that resides in the same web application. If you want to use across applications, you need to place same .ascx control in each application. • Can't hide code of user controls like server controls by compiling into an assembly. Adding User Controls to an WebForms Page: At the top of the .aspx page, add the below line above tag. <!--Register TagPrefix="Test" TagName="TestControl" Src="Test.ascx"--> This d...

Add a Scrollbar(with defined color)

.ScrollBar { overflow: auto; height: 100%; scrollbar-face-color: #c7c57b; scrollbar-highlight-color: #c7c57b; scrollbar-3dlight-color: #c7c5Db; scrollbar-darkshadow-color: #c7c57b; scrollbar-shadow-color: #00000; scrollbar-arrow-color: #000000; scrollbar-track-color: #F9F9DF; }

Populate Date DropDown using Javascript

Set the values of Dropdown list of a date:- There are three dropdown lists for each Day, Month And Year.  we fill through javascript with following way:         var date =" 11/23/2010 "; // Format- MM/DD/YYYY         var mm = date.substring(0,2);         var dd = date.substring(3,5);         var yy = date.substring(6,10);                 document.getElementById(" ddlDay ").value=dd;         document.getElementById(" ddlMonth ").value=mm;         document.getElementById(" ddlYear ").value=yy;

Default Button, asp.net

Default Button for a page:                   <form id="form1" runat="server" defaultbutton="buttonName"> < /form > Default Button for a panel:                    < asp:Panel runat = "server" DefaultButton = "lbHello" > < /asp:Panel > Default in a div:-                    < div onkeypress="javascript:return WebForm_FireDefaultButton(event, 'buttonID')" > < /div > For Linkbutton to make a default page, add below javascript at the end of the page <script type="text/javascript">     var __defaultFired = false; function WebForm_FireDefaultButton(event, target) {     var element = event.target || event.srcElement;     if (!__defaultFired && event.keyCode == 13 ...