-
Change is inivitable
Posted on December 22nd, 2008 No commentsBut why are we afraid of it. For one, it feels awkward. Second, we dont wanna go out of our comfort zones. This is true, we always hesitate to explore unknown territories. The sad thing is sooner or later we have to deal with change and if we don’t it will overrun us and will caugth us offguard.
It took some convincing for me to change coding from php to asp.net. I was getting comfortable with coding php and so I was afraid of moving to asp. But the moment I first get my hands on Visual Studio, I felt compelled by what it can offer. Productivity for one, I have to admit that in php I have to create tons of codes for a simple functionality. And I was so surprised to learn that in asp, someboady already created that function to me. So there I was switching technologies and programming languages and I thought everything will end there, but I was wrong again. The coding language I first used in asp.net is visual basic, which I am also a starter, and the syntax from coding php to VB is very different but fortunately I managed to sneak myway into VB and found myself even coding user controls which are advenced topics. I was able to exploit memberships, roles, profiles with no trouble until I bumped into a problem that starter like me can’t ressolve easily. The solution is presented but not in VB, its in C#, another coding language, still with much persistance, I was able to create the solution I wanted in VB. It seems that change is again lurking in the shadows and it seems like I have no option before it overruns me. So this afternoon I took that step forward in coding c# for the first time and I was able to successfully made it to the first base.
Change can be fearsome. But you will have to deal with it sooner or later. But then again why wait sooner when you can deal with it right now.
-
Child controls on the page level
Posted on December 17th, 2008 1 commentAccessing LoginView’s templated child controls on the page level
I blogged last week about my difficulty to access child controls inside the asp:LoginView server control. Fortunately, I bumped into an article just in time to get the answers I need. So here’s the complete solution to the problem:
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControlsNamespace Fix
Public Class LoginViewFix
Inherits LoginView<TemplateInstance(TemplateInstance.Single)> _
Public Overrides Property AnonymousTemplate() As System.Web.UI.ITemplate
Get
Return MyBase.AnonymousTemplate
End Get
Set(ByVal value As System.Web.UI.ITemplate)
MyBase.AnonymousTemplate = value
End Set
End Property<TemplateInstance(TemplateInstance.Single)> _
Public Overrides Property LoggedInTemplate() As System.Web.UI.ITemplate
Get
Return MyBase.LoggedInTemplate
End Get
Set(ByVal value As System.Web.UI.ITemplate)
MyBase.LoggedInTemplate = value
End Set
End PropertyEnd Class
End Namespace
So theres the code, but how do we use it? First, If you are using visual web developer, you have to click the add new item and choose Class, then rename it to Fix.vb, and the IDE will ask you to place the code to the App_Code Folder, just click yes, then cut and paste this code, and the runtime will automatically compile your code as part of the application. If you will use it on a specific page you have to add a Register directive like this: <%@ Register NameSpace=”Fix” TagPrefix=”fix” %> after the @Page line, then in your code, since we override the <asp:LoginView />, you should now declare it as <fix:LoginViewFix />
Common try it, It worked perfoectly for me.
-
accessing child controls in
Posted on December 11th, 2008 No commentsThis past week, I had a hard time figuring out what I would like to happen in my website.
The scenario is like this:
I want a little image in my website to display a profile’s photo when they user is logged in. So I used asp:LoginView control to accomplish it. Inside this control, I have 2 templates, the anonymoustemplate and loggedintemplate, inside the loggedintemplate, I put an asp:Imaage control and left blank the ImageUrl property so I can programmatically assign it to the profile property called PathToPhoto. The problem is that, in the page_load event of that page, when I tried to assign the ImageUrl property into the persons profile, it says that the image object is not declared. I read MSDN, and what I found out is that, the image control is a child of the loginview control, It took me 3 days of trying to figure out what syntax to use so I can access the members of the child control. Unfortunately I didnt get what I was looking for, So I push my way thru asp.net and tricked it. I used FindControl method of the loginviewcontrol to find out if a certain control is loaded by using its id.Dim MyCollection As ControlCollection
MyCollection = LoginView1.Controls
Dim MyControl As Control
MyControl = MyCollection.FindControl(”ImageID”)
If(Not MyControl Is Nothing)
Dim MyImage As Image = New Image
MyImage.ImageUrl = Profile.PathToPhoto
MyCollection.Add(MyImage)
End IfI know this is not the most effecient way to do it, But at least it serves the purpose, Im gonna have to further search the web for the proper way of doing it.
-
have you read THIS and THAT?
Posted on December 9th, 2008 No commentsIt’s been like months since I post my last blog, and if not for Louie who fixed and kicked the spams out, I wouldnt have blogged again today. It’s been an interesting week so far, prior to Sundays big boxing history match, there was so much anticipation. Of course as a Filipino and as a boxing fan. I am not that ignorant of the ins and outs of the sport. We tend to boast our knowledge and know hows if we dont want to embarass ourselves in front of others. So we tend to be “experts” and boasts our ideas as if we are accredited ESPN broadcasters. And I confess I was not an excemption. But I dont want to share my ideas about the hottest topic and talk so far, I’m sure everybody already got dizzy with tons and tons of articles online discussing last sundays event. I dont even want to mention what the event was. But there was one article that was a complete opposite of what was supposed to be the norm: The Pacquiao frenzy
You read it and you know the blogger is not wrong. Im not KJ for those who are still in the celebration mode, but she is 100% right, and that’s why the Philippines is not moving forward.Thanks to Louie for fixing the spams, and did you know that he doubted the protagonist before he went into the ring….



Recent Comments