Monday, May 23, 2011

Define Access Key In asp.net button control

Flickr Tags: ,

If you want to underline and define the access key in asp.net just like you define in windows application , use the html button element. To produce the same behavior as an asp.net Button control. I set the runat attribute to "server" and use the onclick event to call javascript and onServerClick event to call a server side method.


Here is the code for the page,

<form id="form1" runat="server">



<button id="hbutton1" runat="server" type="submit" accesskey="A" onserverclick="hbutton1_Click" onclick="alert('test');"><u>A</u>dd</button>



</form>




Code-behind, 
 





protected void hbutton1_Click(object sender, EventArgs e)



       {



           Response.Write("hbutton clicked");



       }




When, the page is run, a button is generated with text "Add". When clicked, at first an alert message is shown and then the page postbacks.

Sunday, May 22, 2011

Register Custom User Control in Web.Config File

 

Normally we register any user control or assemblies in page directive of aspx html source if we want to used in any aspx page like.

 


<%@ Register TagPrefix="MyControl" TagName="HeaderControl" Src="Header.ascx" %>
<%@ Register TagPrefix="MyControl" TagName="footerControl" Src="Footer.ascx" %>
<%@ Register TagPrefix="MyAssembly" Assembly="Myassembly" %>
 
 
IF you have header and footer user control and you want to adding on every page or more than one pages then you don’t need to register on every page just register only one time in web.config file and used it multiple time like this way.


<?xml version="1.0"?>
<configuration>
<system.web>
 
        <pages>
        <controls>
        <add tagPrefix="MyControl" src="~/Header.ascx"
        tagName="HeaderControl"/>
        <add tagPrefix="MyControl" src="~/Footer.ascx"
        tagName="footerControl"/>
        <add tagPrefix="MyAssembly" assembly="MyAssembly"/>
        </controls>
        </pages>
        
</system.web>
</configuration>



PDF Arabic watermark using MVC and iTextSharp

PDF full page Arabic watermark using MVC and iTextSharp Download :  Source Code Most of the time we have requirement to  gen...