Thursday, June 28
ASP.Net FormView Control.
319 asp:FormView ID="fvExceptionDetails" runat="server"/asp:
320 AllowPaging="true" DataKeyNames="Oid"
321 OnModeChanging="fvExceptionDetails_ModeChanging"
322 OnPageIndexChanging="fvExceptionDetails_PageIndexChanging"
323 OnItemUpdating="fvExceptionDetails_ItemUpdating">
324 ItemTemplate
325 /ItemTemplate
326 EditTemplate
327 /EditTemplate
328 FormView>
261 protected void fvExceptionDetails_PageIndexChanging(object sender,
262 FormViewPageEventArgs e)
263 {
264 fvExceptionDetails.PageIndex = e.NewPageIndex;
265 DataBindExceptionDetails();
266 }
267 ///
268 /// event invoked only when mode changed through UI.
269 ///
270 ///
271 ///
272 protected void fvExceptionDetails_ModeChanging(object sender,
273 FormViewModeEventArgs e)
274 {
275 fvExceptionDetails.ChangeMode(e.NewMode);
276 if (e.NewMode == FormViewMode.Edit)
277 {
278 fvExceptionDetails.AllowPaging = false;
279 }
280 else
281 {
282 fvExceptionDetails.AllowPaging = true;
283 }
284 if (e.NewMode != FormViewMode.Insert)
285 {
286 DataBindExceptionDetails();
287 }
288 SetJSonclickAttribute();
289 }
322 protected void fvExceptionDetails_ItemUpdating(object sender,
323 FormViewUpdateEventArgs e)
324 {
325 //perform update logic here.
326 fvExceptionDetails.ChangeMode(FormViewMode.ReadOnly);
327 fvExceptionDetails.AllowPaging = true;
328;/span> DataBindExceptionDetails();
329 }
I hope this implementation detail helps. One thing to note would be that I was not using an ObjectDataSource/SqlDataSource to populate the Detailsview.
Sunday, June 24
ASP.Net Page Cycle
Here is the sequence of events and a brief description of the critical ones. I haven't had the chance to use of all of them as yet.
Order top to bottom
PreInit (method: Page_PreInit)
InitThemes and master pages are applied between PreInit and Init, hence PreInit is the last place to programtically modify the selected theme/masterpage. When implmenting "Nested Master pages" while maintaining the ability to see pages in design mode in VS 2005, one needs to set the the change the page's current master page ( the base master page) to the nested master page using this event.
This event is called before any state is restored from the
client response. It is used to prepare the Page for processing the request. Dynamic controls can be added in this event.
Child controls are created between this event and the "InitComplete" event if it is a postback. Also, Control/View State is loaded if it is a postback.
Load
Most commonly used event. It is used to initialize control values on a GET request (!IsPostBack). It is called after
the control/view state has been restored in the Init event on a POST request (IsPostBack) before control passes to the specific event that caused the postback.
To be used to move code from the PreRender event,
the place to make last minute changes to controls.
Used to make any post-event modifications to the controls (Last place to make a change before they get rendered). Recently, I created an editable gridview consiting of 2 columns, one a "State" dropdown and the other "Type" dropdown whose content needed to be changed based on the state selected. I had a Telerik RadAjaxPanel around the Grid and wanted to change the content of the "type" dropdown based on the selection in the "State" dropdown. I had specifically used the PreRender event to tie the "State" dropdown to the "Type" dropdown for every row in the Grid.
Render
UnLoad
Tuesday, June 12
Safari Beta 3 for PC released
A substantial amount of education related community use the mac's and we had a lot of requests to make the sites "Safari" compatible.
This is a big player entering the pc browser market and should make things interesting.
Get it at Safari Beta 3 for PC
Saturday, June 9
Asp.net Release mode Request timeout
Upon talking to an Architect in the company it dawned upon me that there ASP.NET has something called "Request Timeout" (seperate than Session timeout) and this varies between the debug and the release mode. For the debug mode, the duration is a year while for release mode the request timeout is 90 seconds. Hence the abrupt request termination.
He pointed me to this:
Code Better: Peter Gekko: Timeout of an asp.net page
In short the code looks like this:
279 protected override void OnInit(EventArgs e)
280 {
281 timeOut = Server.ScriptTimeout;
282 // Give it 5 hour = (3600 * 5) = 18000 seconds
283 Server.ScriptTimeout = 18000;
284 }
This task can be completed using an ASP.NET Async page or by spawning a separate thread/process. I will make a post on that experience. Till then, this is workable.
Friday, June 8
Javascript gotcha
Please overlook the missing "<" at the start of the script tags, since blogger understandingly has issues with script tags.
script src="../jscalender-1.0/calender.js" />
script src="../jscalender-1.0/calender/look.js" />
script src="../jscalender-1.0/calender/feel.js" />
script language="javascript" type="text/javascript">
function showCalender()
{
}
/script>
In spite of the rendered page containing the above script blocks, the showCalender function was not found and I kept getting a runtime javascript error: Object not found.
IE provided no clues about what is happening, finally when I looked at the source in Firefox with the color scheme, it dawned upon me that only the first script tag is being recognized while the rest are being ignored.
When I changed them to:
script src="../jscalender-1.0/calender.js"> /script>
script src="../jscalender-1.0/calender/look.js" > /script>
script src="../jscalender-1.0/calender/feel.js" > /script>
script language="javascript" type="text/javascript">
function showCalender()
{
}
/script>
So the moral is, close the JavaScript tags with /script> even though the /> might work in certain cases, it baffles you in cases like this.
Saturday, June 2
Books and Tree Surgeon
He says on recruiting, he only looks for 2 qualities in "Smart" and "gets things done".
I also like his "Joel Test" for evaluating employers. Quoting him:
1.Do you use source control?
2.Can you make a built in one step?
3.Do you make daily builds?
4.Do you have a bug database?
5.Do you fix bugs vefore writing new code?
6.Do you have an up-to-date schedule?
7.Do you have a spec?
8.Do programmers have a quite working conditions?
9.Do you use the best tools money can buy?
10.Do you have testers?
11.Do new candidates write code during their interview?
12.Do you do hallway usability testing?
Also interesting is his idea about "hallway usability testing", which I actually implemented on a recent project. Its amazing how much input you get from fellow developers, their criticism, ideas to make the ap better. Hallway testing will stay with me forever.
I recently bought Code Complete, Jeff Atwood swears by this book. I want to read this book, its a big one. He considers it as the bible for all software developers.
I went to Barnes and nobles to read a book called Head First Design Patterns, I really liked the book and concepts were explained so beautifully. I just read about the "Strategy Pattern" and loved the way they presented the materials. I liked the line "Just because you know every OO concept doesnt mean you know how to use they".
some of the concepts I can still remember are
Encapsulate everything that changes
Use Composition over inheritance
Code to Interfaces and not implementations.
I came accross an amazing tool called "Tree Surgeon" which creates a development tree for you. just give it a project name and "voila" it creates a development tree for your project. One of the criticism asp.net received from David Heinemeier Hansson was that asp.net gives you a clean slate when you start with a new project. One has to be knowledgeble enough to setup the testing framework, business layer, build project. If you are new to .Net and not fortunate enough to have a good mentor, you would probably end up with a bloated project. Tree Surgeon does all that for you.
I am going to try and use it in some home project, probably a project to do an existing project using the MVP pattern. I will report my findings.
It will also introduce me to NAnt build system. I have only been using VS 2005 for building my projects uptill now.
Friday, June 1
IIS User
Well, it turns out that it runs under ASPNET in XP (which most developers have) but runs under "Network Service" in Win 2003 which most servers have. I was setting an old website for maintainance purposes and the IIS user needed write permission to a certain folder (for ActiveReports PDFs to be written) .
Cassini, the internal web server for VS 2005 seemed to have access to that folder fine. I then setup a virtual dir for this project on my local IIS and gave ASPNET user write access and it worked. It took me a while to realise that under Win 2003, IIS runs under "Network Service".
Anyways, here is an article about it.
How To: Use the Network Service Account to Access Resources in ASP.NET
Subscribe to Posts [Atom]