InternetException

InternetException

About coding and whatnot

Notes on .NET, C#, self-hosted LLMs, Android and whatever else I break on the way. Written since 2012, migrated from WordPress to a few static files. Who is writing this?

Server controls in separete assembly part 2

· 795 words · ~3 min read · updated · in .NET, ASP.NET, C#

Yesterday I was writing about creating server controls in separate assembly . Today I will cover more complicated example then simple “Hello World!” control. My goal was to create text box that will take handler method to run when validation event will be triggered, and when validation fail will show appropriate message. Text box with builtin validation would be nice, since you always should validate user input , right? But lets start creating our control.

Read the whole thing →

Server controls in separate assembly

· 394 words · ~1 min read · updated · in .NET, ASP.NET, C#

In my project I wanted to create text box control with builtin configurable validation. ASP.NET definition in .aspx or .ascx file would get validation function by name. But I do not wanted to create just .ascx file with text box. I could not then reuse that control in other projects and it certainly would be nice, right? Creating such server control from code is not hard, but maintainability of HTML code in C# (it cannot be done other way) is not good. It’s pain really. Why Microsoft would create way to automatically create C# code from .ascx, .aspx files is mystery for me.

Read the whole thing →

Better algorithm for finding UpdatePanel that will be updated during page request.

· 496 words · ~2 min read · updated · in .NET, ASP.NET, C#

#UpdatePanel

Other day I was experimenting with finding which UpdatePanel will be updated during page post back. I found out that my solution was not working correctly for complex triggers, like user controls with custom events, which will trigger async postbacks and update of panel. Or for grids with buttons. It was big issue. Also it was not pointing to correct UpdatePanel if name of control was not entirely unique (for example when you have multiple same custom controls on page). It would return first panel, even if it wasn’t updating.

Read the whole thing →

Display message on client from anywhere in code with ASP.NET

· 890 words · ~4 min read · updated · in .NET, ASP.NET, C#

#UpdatePanel

When I was working with WinForms application in previous work I have found one of most useful feature, ability to show some message to the client. For example user cannot edit some entity in particular time (it is being edited by someone else) or should change password because it will expire in x days. I wanted to do something similar in my web application.

Read the whole thing →

Getting private field or property from object

· 201 words · ~1 min read · updated · in .NET, C#

Yesterday I was playing with finding all UpdatePanel controls on page during generating response in ASP.NET. Since object with this information is private itself and collection of panels is private in that object, I had to write some code to extract that data. I ended up with to extension methods for Object type, for getting private field an private property. It’s pretty straightforward, besides one thing: since member is private. And we don’t know in witch type exactly (every type in base/descendant hierarchy have it’s one private members) we have to search them all. So this is final code:

Read the whole thing →