ModalPopupExtender + Dynamic Controls + PostBacks + UpdatePanel

by Digvijay 30. October 2008 04:20

I spent almost 3 hours today trying to figure out what is wrong with one of the WebControl I am writing. The component reads up a XML file and based on that allows for dynamically populating a Data Entry interface - absolutely no markup in the aspx and all the dynamically created controls can callback/raise events to the container page when some events occur. However i noticed in case of ModalPopupExtender i can not get back any events whatsoever and if i add a update panel it just recreates itself then and there and all the entered data is gone!!!

 

What was i doing wrong!

As one of my colleague pointed out i should have used INamingContainer on each of the dynamic controls that i was making because they in turn create some dynamic child controls. And as soon as i implement INamingContainer on the base control all worked just fine. Its weird but it works. I guess its time to dig deep in the INamingContainer!!!

public interface IInputControl : INamingContainer
{
........
}

Hope someone finds this tip useful.

 

 

Tags:

AJAX | ASP .NET | WebControls

Web.Config trick : Namespaces and WebControl Libraries

by Digvijay 15. September 2008 23:19

There is quite a useful feature since ASP.NET 2.0 which I did not observe earlier. I needed it now so here it is:

To be able to add a specific tag prefix and specify namespaces in a central location (web.config) such that it allows for specifying the that ASP.NET runtime can find when we import it an ASPX pages. In ASP.NET 1.x one had to use the intrusive @Import directive:

<%@ import namespace="MyCompany.App.WebControls" %>

However, now in ASP.NET 2.0 one can add default namespaces into the web.Config files as shown below:

 

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
        <pages>
           <namespaces>
               <add namespace ="System.IO" />
               <add namespace="MyCompany.App.WebControls"/>
           </namespaces>
         </pages>
         <controls>
               <add tagPrefix="mytag" 
                         namespace="MyCompany.App.WebControls" 
                         assembly="MyCompany.App.WebControls" />
         </controls>
</system.web>
</configuration> 

just this and you can use mytag as a control prefix in your markup, if you are used to writing it by hand rather than drag and drop!

I found it quite handy and I hope you can find a good use for it too!!!

 

Tags:

ASP .NET | WebControls

How to post a form without user interaction in a ASP.NET page

by Digvijay 15. August 2008 05:04

Recently I came across a problem where I needed to post a form without any user intervention, kind of like just populate the fields on the go and just submit when the page is ready. It was quite simple to do actually!

 

Here is the code fragment for the explanation (actually this is not specific to ASP .NET but would work with any kind of HTML Form)

 

Step 1:

just assign your html form element a name like

< form name="frmsubmitdata" >

</form>

Step 2:

Next, at the end of page add the following JS block:

<script language="javascript">
frmsubmitdata.submit();
</script>
If you find it useful, leave me a comment!
Technorati Tags: ,

Tags:

ASP .NET | Code Snippets

Adding Intellisense to your custom ASP.NET server controls

by Digvijay 12. August 2008 02:23

HTML Editor Intellisense can be added by going through the next steps

1.) Create XSD file that describe your web control

2.) Add to your web application local folder the XSD file and name it as your web controls library (TagPrefix)

3.) Add to your web form body the following attribute – 

xmlns:yourControlLibPrefixName ="urn:http://schemas.myCompany.org/myTechnology"

The attribute value should be the same as it is in the XSD file targetNamespace attribute

4.) yourControlLibPrefixName - Should change to your control library (TagPrefix) name.

5.) That’s all

BTY – ASP Web Controls are all define in asp.xsd file in the framework schema folder. The XSD definitions for grid, list box and so on located there. Its nice to open the file and see how Microsoft defines the elements of the ASP.NET controls.

XSD Web Control Generator Tool:

In order to create XSD for your custom web controls intellisense definitions I recommend on the following XSD generator supplied by blue vision software- I find it today using Google - it really cool and free!!!

Tags:

ASP .NET | Web Controls

 

About Digvijay

  Digvijay Chauhan
I am a developer living in Stockholm, Sweden and I love to program and work on cutting edge technologies in the Microsoft Technology space.

LinkedIn Twitter StackOverflow

Certifications

Digvijay Chauhan Microsoft Certification Logo

Other Pages

RecentPosts

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar

Most comments

Live Traffic

Live Traffic Feed
  Västra Frölunda, Vastra Gotaland arrived from digvijay.eu on "blank_page"

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

Translate