Off late I developed another new aspect of my field and I am now challanging myself now into yet another field of programming..... GAME DEVELOPMENT.
Startd off with a very simple yet very effective tutorial found at http://blogs.msdn.com/coding4fun/archive/2006/11/03/940223.aspx
The moment I had everything set up nicely for my first DirectX application to run, it failed with a very strange exception
"NotAvailableException"
Well after a decent amount of search... I could finally get the solution.. and was really very embarassed to see that to be a problem..
I was using the Generic Video Card Drivers that were being installed by default by windows and all it needed was to install the latest Video Card Drivers from the vendor's site and VIOLA...
It works..
Learning - Before any Dx programming, make sure you are up to date with the Drivers for all your hardware....
Njoy :)
Just recently I started learning Silverlight and its pretty cool. I am loving it and trying to find new things everyday out of it.
Today, while working with the XAMLs and XAPs, I noticed that the Silverlight controls when referred onto an ASPX page, uses the XAP as the source.
Now thats where I had an issue.
I had created quite a few UserControls (XAMLs) on a single XAP and had no clue how to distinguish them on the ASPX page.
Here is the solution to it.
For the purpose of differenciating between the two controls, we use its InitParameters property.
As shown in the image above, I had multiple XAMLs for a single XAP
Now I had two ASCX user controls. One of them needed Page.Xaml and the other needed TeamToolbar.xaml.
So to distinguish between the two, I had the following declarations:
On the Page.Ascx -
<asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/AllCoders.xap" InitParameters="ControlID=Page" Width="100%" Height="100%">
And on the TeamToolbar.ascx -
<asp:Silverlight ID="Xaml2" runat="server" Source="~/ClientBin/AllCoders.xap" InitParameters="ControlID=TeamToolBar" Width="100%" Height="100%">
And on the App.xaml.cs, where its all initialized, we need to check which control is to be loaded.
In the Application_Startup method, this is how we need to check for it.:
Just recently, while working on a project, I stumbled upon a need to fetch images from the SQL Database and display them in the image control on the page. public void ProcessRequest(HttpContext context)
I did a bit of research and landed upon a concept of using GENERIC HANDLERS for that purpose.
I found that really useful as compared to any other approach of saving the files to disk and setting the URLs etc.
Here is what can be done:
1. Add a new GENERIC HANDLER (ImageDisplay.ashx) to the project.
2. Set the ImageControl's ImageUrl to this ashx page..imgDisplay.ImageUrl = "ImageDisplay.ashx?imageId=1";
where imageId is the Database ID of the image that needs to be fetched.
3. Now write code to fetch data from Database for that imageId in the ProcessRequest event of the ashx page.
4. The method GetImageById would depend upon the Database and data-type that you have for the column for image. Since I had a MySQL database with BLOB column, which can hold a Byte[], the method was quite simple for me and I just had to pull it out from Database and insert it into a Byte[] object.
{
Int32 imageId = Convert.ToInt32(context.Request.QueryString["imageId"]);
// This is the function that returns the Byte Array from the Database
Byte[] pict = GetImageById(imageId);
context.Response.ContentType = "image/bmp";
context.Response.OutputStream.Write(pict, 0, pict.Length);
}
-- Ashutosh
Recently, I encountered the problem quite similiar to the one above.....TabContainer cannot have children of type
to be precise...
'System.Web.UI.WebControls.Repeater'
I googled quite a bit for this error, but could not find much about it.. No wonders.. It was a careless mistake that I had made. Here is the control that caused this issue....<cc1:tabcontainer id="tabToolbox" runat="server">
<cc1:tabpanel id="pnl" headertext="Most Popular">
<contenttemplate>
<asp:repeater id="rptMostPopular" runat="server">
<itemtemplate>
<asp:linkbutton id="lnkPopular" runat="server" text=""></asp:linkbutton>
</itemtemplate>
</asp:repeater>
</contenttemplate>
</cc1:tabpanel>
<cc1:tabpanel id="pnl2" headertext="Most Viewed">
<contenttemplate>
<asp:repeater id="rptMostViewed" runat="server">
<itemtemplate>
<asp:linkbutton id="lnkPopular" runat="server" text="">&jt;/asp:linkbutton>
</itemtemplate>
</asp:repeater>
</contenttemplate>
</cc1:tabpanel>
<cc1:tabpanel id="pnl3" headertext="Most Emailed">
<contenttemplate>
<asp:repeater id="rptMostEmailed" runat="server">
<itemtemplate>
<asp:linkbutton id="lnkPopular" runat="server" text=""></asp:linkbutton>
</itemtemplate>
</asp:repeater>
</contenttemplate>
</cc1:tabpanel>
</cc1:tabcontainer>
Well...... A very simple reason for getting this error, even on the designer and also at runtime..
I FORGOT THE TAG "RUNAT=SERVER" WHILE DESCRIBING THE TAB PANELS AND therefore could not get the tab-panels to be server side...
This is what raised the issue.
A simple addition of RUNAT=SERVER solves the issue...
Hope this would help someone in need... :)
--Ashutosh
Just recently, I came across a situation where I needed to display a modal popup dialog box from my left navigation bar links.
<a href='' onclick='javascript:fncShowPopUp();return false;'>Edit Profile</a>
function fncShowPopUp(){var popUpExtender = $find("ModalPopupExtender");if(popUpExtender){popUpExtender.show();}return false;}
This morning while working with the Global.asax to handle my application level errors, I faced a very strange problem.
Despite of having a Error Handling routine in my Global.asax file, I was unable to trap an exception from the application and instead it was just throwing up a Message Box with the exception message.
So all my routine of logging the error and recording it into the DB was going without being executed.
After a fair bit of research, the UPDATEPANEL came out to be the culprit.
By its very design, UpdatePanels are designed not to bubble up the exception by default and thus it just pops up a Message Box and thus the Error handling routine in Global.asax was never called.
So to call this and feature a full post-back, we need to handle the AsyncPostBackError event of the Script Manager. Here is the code for that.
1. Add the following attribute to the Script ManagerOnAsyncPostBackError="scriptMan_AsyncPostBackError"
2. Create the event handler on the code behindprotected void scriptMan_AsyncPostBackError(object
sender, AsyncPostBackErrorEventArgs e)
{
MethodInfo preserveStackTrace =
typeof(Exception).GetMethod("InternalPreserveStackTrace", BindingFlags.Instance BindingFlags.NonPublic);
preserveStackTrace.Invoke(e.Exception, null);
throw e.Exception;
}
This would bubble up the event and Global.asax would be able to catch the exception thrown and here we could have our all cleanup routine for error trapping and recording.
-- Ashutosh
