Tuesday, August 29, 2006

DataBinder.Eval On the fly data binding

[asp:TemplateColumn]
[ItemTemplate]
[asp:HyperLink Target=_blank NavigateUrl='<%# "http://www.openquals.org.uk/openquals/qualificationDetails.aspx?QualificationID=" + DataBinder.Eval(Container, "DataItem.QualificationID") %>' Runat=server]More[/asp:HyperLink]
[/ItemTemplate]
[/asp:TemplateColumn]

Monday, August 28, 2006

Using a Literal control

litLinks is a LITERAL CONTROL declaration:

protected System.Web.UI.WebControls.Literal litLinks;


// declare string
string strLinks;

// Put HTML into the string
strLinks = "[a href ='TPPMain.aspx?requestId=" + strRequestId + "&view=qual']Qualification[/a]&nbsp[a href ='TPPMain.aspx?requestId=" + strRequestId + "&view=unit']Units[/a]";

// add the string to the literal control
litLinks.Text = strLinks;

How to get Internet radio working in MCE at a click of a button

Hi all,

Yesterday I have added some cool features to my MCE.

I have added an internet radios to it that can be accessed from the main menu. I live in UK and I like to listen to Czech radios that broadcast over the internet. I was looking to find an easy was of doing this from the MCE that sits in the living room.

I have faced a few problems and I thought it might be good to share it with the world.

First off you need an MCE Add-in to allow you to do this I have used this one called Web Media:

http://www.mcesoft.nl/index.php?option=com_content&task=view&id=25&Itemid=122

You have to register with them to be able to use it (just want your email that has to be valid)
It is a Media Release Candidate 1.3 but I tested it and it works quite well.

So once you download this and install it all you need to do is add the link to the live stream that is a *. Asx file

Now this might seem easy done but it isn’t. Usually any radio that uses windows media player that plays in a small popup window that is just an IE window or in some sort of player of its own. But once it opens you have no idea even about the URL of the page and especially not about the URL of the stream.

What you need now is a browser that supports Tabbed browsing (I have used Netscape 8 to do this)

You need to go to the site of the radio and then click on the link to LISTEN LIVE. What happens in Netscape is that the new window will open in a tab rather than in a pop up window. So now you see the URL of the page that plays the live stream but this still isn’t the URL of the stream itself.

You need to do view / Page source and look into the HTML code used to generate this language and if the page is using windows media player web control you can look at the code and locate this node:

PARAM NAME="URL" VALUE="http://www.live.cz/radio/evropa2-64.asx">

Or just search the file for .asx and you will get the URL of the stream itself.

You can now use this as the URL of the internet radio station and add it to the Web Media in your MCE and there you go you can now listen to the internet radio from your MCE at a click of a (remote control) button.

http://www.onev.com/mcc/store.htm
http://www.ehomeupgrade.com/entry/2171/media_center_communicator

Wednesday, August 23, 2006

Page content from a file ASP.NET

First create a textfile with HTML code in it (or just plain Text)

Create a class to read the stuff from files

public class LearningProvider
{

string templatedirectory=System.Web.HttpContext.Current.Server.MapPath("/NAALearningProvider/Controls/_Templates/Content/");
public LearningProvider()
{
//
// TODO: Add constructor logic here
//
}
public string ReadTemplate(string templateFile)
{
StreamReader streamReader=new StreamReader(templatedirectory+templateFile+".txt");
return Regex.Replace(streamReader.ReadToEnd(),"\r\n","
");

}
}

Now use this code to use class from the ASPX page

LearningProvider lp=new LearningProvider();
lblContent.Text = lp.ReadTemplate("LPUpdateDetailsConfirm");

Tuesday, August 22, 2006

T-Mobile Provider and Customer Services HELL

Just wanted to let everyone know about T-Mobile and what a shitty company they are. I have canceled my contract with O2 that I was satisfied with but got a better new customer contract with cashback and all with T-Mobile. I have also transfered my number to them which was the biggest mistake ever.
First few weeks I was not making many phone calls but when I wanted to make one I would ussualy get NETWORK BUSY message or I would go straight to the voicemail of the person I was calling and it would never ring his phone.
The signal with T-Mobile in Northern Ireland is just terrible there is no other word for it sometimes you get one bar sometimes two max i ever got was 4 and scale of my phone has about 8 bars.
A part from not having any signal and network busy, sometimes when I have the luck of making a call it always gets cut after up to 3 minutes and I can hear the three sounds beep-beeep-beeeep and that's the end of the call.
So I have tried to complain and I told them that I want them to give me my PAK code so I can port my number and leave. They said there is a 200 GBP disconnection fee!!! I said to them that they are not delivering the service. The girl would not do anything for me at all would not even put me thru to her supervisor however I have insisted on this 3 times. She gave me an address for complaints so I have written there.
After about 2 weeks I got a phone call from them saying that if it happens again I have to ring them and report it so that they can trace it. And they have lured me into a one month free line rental. Obviously it keeps on happening and I rang them and have two occasions of this logged on to my account. Noone contacted me since so I have written them another letter. Stating that I require them cancel the contract and give me my number as they have failed to deliver the service I am paying for.
After this they took the position of a dead bug - No response from them at all.
Now I have changed jobs and at this new place where I work in Antrim, Northern Ireland there is no signal whatsoever with T-Mobile. However O2 Orange and Vodafone do have at least 4 bars...
So I have written my dearest provider a third letter stating this and how they did not respond to my two letters in a proper way. Now I have only send it this morning so I would have to wait and see.
I am really frustrated the mobile is no use to me I cant use it at all for at least 8 hours every working day that I am at work 9AM - 5PM and they wont let me leave cos I am in a 12 month contract.
Did anyone faced something similar? What should I do with them? any suggestions anyone?

Datagrid with CheckBoxes in C# example

First create a datagrid with checkboxes in it:

asp:TemplateColumn
ItemTemplate
asp:CheckBox Runat="server" ID="chkReq" Text="Request"

/asp:CheckBox
/ItemTemplate
/asp:TemplateColumn


Second the code:


private void btnConfirm_Click(object sender, System.EventArgs e)
{
// check if there is not two selected in the whole grid
if (!CheckSelectionError() == true)
{
// Display Error Message
lblMessage.Text = "Error some row has both checkboxes selected";
return;
}
else
{
lblMessage.Text="All checks fine";
}
// if no process all rows row by row
SaveSelection();
}


Now the loop trhu all items in the grid and do stuff with them:

// function to save the selection to the DB
public bool SaveSelection()
{
// declare instance of LAR
NAA.DAL.LAR.Reader objLar = new NAA.DAL.LAR.Reader();
// declare variables
string strULN;
int intQualID;
string strQualDate;
string strCentreName;
string strEndorsement;
CheckBox chk = new CheckBox();
// check each datagrid item
foreach (DataGridItem i in dgQualifications.Items)
{
// find chkDec
chk = (CheckBox) i.FindControl ("chkDec");
// check if it is selected
if (chk.Checked == true)
{
// Decline this row
}
// find chkReq
chk = (CheckBox) i.FindControl ("chkReq");
// check if it is selected
if (chk.Checked == true)
{
// get the details
strULN = dgQualifications.Items[i].Cells[0].Text;
intQualID = dgQualifications.Items[I].Cells[2].Text;
strQualDate = dgQualifications.Items[1].Cells[3].Text;
strCentreName = dgQualifications.Items[1].Cells[4].Text;
strEndorsement= dgQualifications.Items[1].Cells[5].Text;
// Request this row
objLar.SavePossibleQualificationClaim(strULN, intQualID, strQualDate, strCentreName, strEndorsement);
//objLar.FlagPossibleClaimAsProcessed();
}
}
// if it got here all ok
return true;
}

Method to check if not two checkboxes on one row are selected:

// function to find out in not both checkboxes were checked
public bool CheckSelectionError()
{
CheckBox chk = new CheckBox();
int intNoOfChecked;
// check each datagrid item
foreach (DataGridItem i in dgQualifications.Items)
{
intNoOfChecked = 0;
// find chkDec
chk = (CheckBox) i.FindControl ("chkDec");
// check if it is selected
if (chk.Checked == true)
{
intNoOfChecked += 1;
}
// find chkReq
chk = (CheckBox) i.FindControl ("chkReq");
// check if it is selected
if (chk.Checked == true)
{
intNoOfChecked += 1;
}
// make a decision
if (intNoOfChecked == 2)
{
return false;
}
}
// if it got here all ok
return true;
}

Optionaly this could be done using two option boxes but there will be a need of Javascript to uncheck the other one when one is checked