Showing posts with label microsoft. Show all posts
Showing posts with label microsoft. Show all posts

Wednesday, March 28, 2012

Programatically adding UpdatePanel?

I want to programatically add an updatepanel control on a button click.

I tried adding a reference to Microsoft.Web.Atlas.dll and then creatinga System.Web.UI.UpdatePanel control but the app does not compile - withnamespace does not exist error.

Does anyone know what I should be doing or if this is possible at all?

Thanks !

you would need to import the following

Imports Microsoft.Web.UI

Then, you can create an instance of the UpdatePanel like this:

Dim UP As New UpdatePanel

Hope this works for you.


Thanks it works ... I was using System.Web.UI which was the problem
Now that I have this I'm trying to add content to the updatepanel.

I can set most of the properties, add triggers without problems.

However when I try to execute it - it gives an error saying "A ContentTemplate must be specified".

Whats the easist way to do this. I haven't found any documentation on programatically adding a contenttemplate.

Any help would be greatly appreciated!
I'm looking for the same thing myself and haven't found any answers.
You'll need to create a class that implements ITemplate, create an instance of that and set the content template property to that instance.

try this

protected

overridevoid OnInit(EventArgs e)

{

updatePanel.ContentTemplate =

newCompiledTemplateBuilder

(

newBuildTemplateMethod(CreateAtlasUpdateContent));

}

public

void CreateAtlasUpdateContent(Control container)

{

container.Controls.Add(yourcontrol);

}


dont know if this will come in handy with anyone but what i did to get around the template error was

have a class with the following:

PublicClass AjaxControl :Inherits Microsoft.Web.UI.UpdatePanelProtectedOverridesSub OnInit(ByVal eAs System.EventArgs)Me.ContentTemplate =New TemplateBuilderMyBase.OnInit(e)EndSubEndClass

Then whenever i needed to create a control that was surrounded by the update panel i would inherit this class and could just then put me.controls.add() as usual.

probs useless to you all, but works for me :)


Even if you got past the coding issues, you still can't add an UpdatePanel once InitComplete has fired (which is pretty early in the lifecycle) so you're not going to be able to accomplish what you set out to do, which I think was to add an UpdatePanel dynamically.

HTH

Has anyone been able to dynamically add an UpdatePanel to a page?

I got so far - and then I got the error:

"The UpdatePanel 'panel1'was not present when the page's InitComplete event was raised."

Is there any way around this?

Wade.

Monday, March 26, 2012

public override void Dispose() throws error after loaded

in Extender Control Base I have this code

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design","CA1063:ImplementIDisposableCorrectly", Justification ="Using correct base class implementation and simply setting a flag on the way")]public override void Dispose() {this._isDisposed =true;base.Dispose(); }

After this runs I get an error in ScriptResource.axd

if (typeof(browserHandler) !=='function')throw Error.invalidOperation(Sys.Res.eventHandlerInvalid);
I am using IE 7
[Behaviors: This method releases all unmanaged resources held by the current instance. When theexplicitDisposing parameter istrue, this method releases all resources held by any managed objects referenced by the current instance. This method invokes theDispose() method of each referenced object.]

[Overrides: Override this method to dispose of resources allocated by types derived from WaitHandle. When overridingDispose(Boolean), be careful not to reference objects that have been previously disposed in an earlier call toDispose orClose .Dispose can be called multiple times by other objects. ]

[Usage: This method is called by the publicSystem.Threading.WaitHandle.Dispose(System.Boolean) method and theSystem.Object.Finalize method.Dispose() invokes this method with theexplicitDisposing parameter set totrue. System.Object.Finalize invokesDispose withexplicitDisposing set tofalse .]

Take a look at

http://www.codeproject.com/useritems/idisposable.asp

for examplees


I'll take a look at that link. thanks.

Saturday, March 24, 2012

Q From MS ajax sample

Why microsoft uses the code:

if ( typeof(Sys)!=="undefined" ) Sys.Application.notifyScriptLoaded() ;

and not

if ( typeof(Sys)!= "undefined" ) Sys.Application.notifyScriptLoaded() ;

Is it the same?

Leeor

=== and !== differ from == and != in that they avoid type coersion.

In this particular case, I'm not sure there's a difference, but in general the "strict equals" (=== and !==) operands are usually what you want.


Sorry but I didnt understand theprincipal difference


It's all about type coercion:

"100" == 100 // returns true, because the types are coerced
"100" === 100 // returns false, because the types have to first match before the comparison is even performed

Does that make sense?


That sounds alot betterWink

Thanks man

Wednesday, March 21, 2012

Question regarding AJAX, Blinq etc

Ive noticed lately Microsoft are introducing AJAX, Atlas, WPF,Blinq and many more new technologies.

My question is based on myself being a relatively newcomer to ASP .Net 2.0 and dont know everything but know some as ive developed more with applications rather than websites. So am i wasting my time in learning ASP .Net 2.0 as these new technologies means ASP .Net 2.0 will become "redundant" or "not a standard"? should i concentrate learning these new technologies or continue learning ASP .Net 2.0 as these new technologies will fall in place at some stage?

Thanks

EssCee

ASP.Net 2.0 is the foundation for these technologies, so in my opinion learning asp.net first is fundamental to understanding these other "enhancement" technologies. For example, ASP.NET AJAX (formerly Atlas) is simply an extension to asp.net...not a seperate technology unto itself. Blinq is basically dynamically creating asp.net pages from a data source...so again, built on top of asp.net.

WPF is slightly different I believe in that it is centered around building windows client applications...specifically building nice GUI's to windows client applications. It is more an extension of .Net as a whole than just ASP.NET...I think anyway (someone feel free to correct me).

Matt