I was recently contacted by a potential client... He wanted to know how to imbed YouTube videos into a his Ebay Listing. And his video was only 15 seconds - and had the product rotating.. He wanted it to auto-start, and loop.
The above video gives great easy-to-use instructions...
If you want to do some of this by hand, consider the following:
YouTube Looping Tricks
Thursday, January 20, 2011
Friday, January 14, 2011
DataTable from XML & data chema - Correct datatypes filling from xml
I have filled some datatables (datasets which contain 1 datatable) from xml.
//read xml / api into dataset..
DataSet ds = new DataSet();
ds.ReadXml("http://www.myuapi.com?request=KeyId=" + uuid);
MyRadGrid.DataSource = ds.Tables[0];
The problem is that all the data is looked at like string... some is really integer or doubles.. When we do filtering using Telerik filters... it needs to have the right datatype to filter properly...
SOLUTION: stay tuned...
I put the data into a linq query... and typed the items in the list... code to follow soon.
//read xml / api into dataset..
DataSet ds = new DataSet();
ds.ReadXml("http://www.myuapi.com?request=KeyId=" + uuid);
MyRadGrid.DataSource = ds.Tables[0];
The problem is that all the data is looked at like string... some is really integer or doubles.. When we do filtering using Telerik filters... it needs to have the right datatype to filter properly...
SOLUTION: stay tuned...
I put the data into a linq query... and typed the items in the list... code to follow soon.
Sunday, December 12, 2010
Remove duplicate Items RadComboBox - Telerik
I had a puzzle recently with a RadComboBox...
I have a sql query that took a long time to run... sometimes 30 seconds, due to the huge database size and the complex query...
To populate a RadGrid - I bound it to a SqlDataSource. But I also needed dropdowns to filter this grid - and this needed to be bound to unique items in a column of that grid... I didnt want to do another db query to get a filtered version of the same info - so I bound it to the SAME SqlDataSource - and cached the datasource to minimize calls.
[asp:SqlDataSource ID="MySqlDataSource" EnableCaching="true" CacheDuration="180"
runat="server" OnSelecting="MySqlDataSource_Selecting"
ConnectionString="[%$ ConnectionStrings:mySqlConnectionString %]"
SelectCommand="SELECT * FROM vwBundlesForSale "]
[/asp:SqlDataSource]
However, this made there to be duplicate items in my dropdown... and the data was not sorted.
If you want to Sort and Filter for unique items in a Telerik RadComboBox, use something like this:
IN ASPX PAGE:
[telerik:RadComboBox ID="CoatComboBox"
runat="server" DataSourceID="MySqlDataSource" DataTextField="CoatName" DataValueField="CoatName" AllowCustomText="false" EnableItemCaching="true" Width="165px" DropDownWidth="260px" OnDataBound="SortAndNoDups_OnDataBound" AppendDataBoundItems="true" ......
IN CS CODE-BEHIND
protected void SortAndNoDups_OnDataBound(object sender, EventArgs e)
{
RadComboBox fixComboBox = (RadComboBox)sender;
string selectedText = string.Empty;
if (fixComboBox.SelectedIndex >= 0)
{
selectedText = fixComboBox.SelectedValue;
}
fixComboBox.SelectedIndex = -1;
fixComboBox.Filter = RadComboBoxFilter.Contains;
fixComboBox.Sort = RadComboBoxSort.Ascending;
fixComboBox.SortItems();
string priorItem = "";
for (int i = 0; i < fixComboBox.Items.Count; i++)
{
try
{
RadComboBoxItem itm = fixComboBox.Items[i];
if (itm.Text == priorItem)
{
fixComboBox.Items.Remove(itm);
i--;
}
else
{
priorItem = itm.Text;
}
}
catch
{
break;
}
}
if (selectedText != string.Empty)
{
try
{
fixComboBox.SelectedValue = selectedText;
}
catch { }
}
}
protected void MySqlDataSource_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
e.Command.CommandTimeout = 0; //prevents SqlDataSource timeout after 30 seconds
}
I have a sql query that took a long time to run... sometimes 30 seconds, due to the huge database size and the complex query...
To populate a RadGrid - I bound it to a SqlDataSource. But I also needed dropdowns to filter this grid - and this needed to be bound to unique items in a column of that grid... I didnt want to do another db query to get a filtered version of the same info - so I bound it to the SAME SqlDataSource - and cached the datasource to minimize calls.
[asp:SqlDataSource ID="MySqlDataSource" EnableCaching="true" CacheDuration="180"
runat="server" OnSelecting="MySqlDataSource_Selecting"
ConnectionString="[%$ ConnectionStrings:mySqlConnectionString %]"
SelectCommand="SELECT * FROM vwBundlesForSale "]
[/asp:SqlDataSource]
However, this made there to be duplicate items in my dropdown... and the data was not sorted.
If you want to Sort and Filter for unique items in a Telerik RadComboBox, use something like this:
IN ASPX PAGE:
[telerik:RadComboBox ID="CoatComboBox"
runat="server" DataSourceID="MySqlDataSource" DataTextField="CoatName" DataValueField="CoatName" AllowCustomText="false" EnableItemCaching="true" Width="165px" DropDownWidth="260px" OnDataBound="SortAndNoDups_OnDataBound" AppendDataBoundItems="true" ......
IN CS CODE-BEHIND
protected void SortAndNoDups_OnDataBound(object sender, EventArgs e)
{
RadComboBox fixComboBox = (RadComboBox)sender;
string selectedText = string.Empty;
if (fixComboBox.SelectedIndex >= 0)
{
selectedText = fixComboBox.SelectedValue;
}
fixComboBox.SelectedIndex = -1;
fixComboBox.Filter = RadComboBoxFilter.Contains;
fixComboBox.Sort = RadComboBoxSort.Ascending;
fixComboBox.SortItems();
string priorItem = "";
for (int i = 0; i < fixComboBox.Items.Count; i++)
{
try
{
RadComboBoxItem itm = fixComboBox.Items[i];
if (itm.Text == priorItem)
{
fixComboBox.Items.Remove(itm);
i--;
}
else
{
priorItem = itm.Text;
}
}
catch
{
break;
}
}
if (selectedText != string.Empty)
{
try
{
fixComboBox.SelectedValue = selectedText;
}
catch { }
}
}
protected void MySqlDataSource_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
e.Command.CommandTimeout = 0; //prevents SqlDataSource timeout after 30 seconds
}
Wednesday, November 10, 2010
C# ?? two question marks
You ever wonder what ?? means in C# language?
Its a cool shortcut for checking for nulls and returning a value...
I find it very useful when working with Linq queries... that may return some nullable fields..
Great article:
http://stackoverflow.com/questions/446835/what-do-two-question-marks-together-mean-in-c
Its a cool shortcut for checking for nulls and returning a value...
I find it very useful when working with Linq queries... that may return some nullable fields..
Great article:
http://stackoverflow.com/questions/446835/what-do-two-question-marks-together-mean-in-c
Tuesday, September 7, 2010
Soap Call using Javascript
There are many times now that I need to make a soap call to an XML web service.... from the client (javascript). If, for example, you need to update the database... but want to use Javascript to do so out of process - without a postback...and with minimal data passed to the server... this is a great approach.
After a lot of research and testing I have found and do recommend the following js tool for any of my colleagues:
http://www.codeproject.com/KB/ajax/JavaScriptSOAPClient.aspx
Using this, it is a simple trick to call the database...
[script]
var url = "../../ws/MyWebService.asmx";
function HelloWorld() {
var pl = new SOAPClientParameters();
pl.add("yourName", "Robert the Great");
SOAPClient.invoke(url, "HelloTo", pl, true, Hello_CallBack);
}
function Hello_CallBack(resultData) {
alert("Hello_CallBack: " + resultData);
}
[/script]
After a lot of research and testing I have found and do recommend the following js tool for any of my colleagues:
http://www.codeproject.com/KB/ajax/JavaScriptSOAPClient.aspx
Using this, it is a simple trick to call the database...
[script]
var url = "../../ws/MyWebService.asmx";
function HelloWorld() {
var pl = new SOAPClientParameters();
pl.add("yourName", "Robert the Great");
SOAPClient.invoke(url, "HelloTo", pl, true, Hello_CallBack);
}
function Hello_CallBack(resultData) {
alert("Hello_CallBack: " + resultData);
}
[/script]
Sunday, July 25, 2010
Optimizing a website for Speed
There are several techniques that can be used to optimize your website for speed. And remember, one of the things Google considers now is your website speed.
The basics include
1) Compressing resource files (like .css and js)
2) Minimizing the number of files linked/imbedded in a web page.
3) Optimizing the size of images used on the web page
NOTE: if a css file referenced on all pages references multiple images for backgrounds - make sure that most of them are really used on all pages. If not - consider referencing them only on pages where needed.
So for my websites, I am taking all the common css files for a page (often separated for specific wigits or sections) and compressing them into one .css file for the site. I do the same for the javascript... Of course, this is only after the site is approved for look/feel by the client so I don't have to redo this. And I keep the un-compressed versions available for later editing if needed... since these will have all my comments and easy-to-read formatting.
If a .css or .js file is only needed on a few pages, I only include a compressed version of that file where needed. (and I use the compressed version here too...) But overall, this has proved to be a good strategy for minimizing website overhead - and increasing speed.
TOOLS TO BOOKMARK:
The basics include
1) Compressing resource files (like .css and js)
2) Minimizing the number of files linked/imbedded in a web page.
3) Optimizing the size of images used on the web page
NOTE: if a css file referenced on all pages references multiple images for backgrounds - make sure that most of them are really used on all pages. If not - consider referencing them only on pages where needed.
So for my websites, I am taking all the common css files for a page (often separated for specific wigits or sections) and compressing them into one .css file for the site. I do the same for the javascript... Of course, this is only after the site is approved for look/feel by the client so I don't have to redo this. And I keep the un-compressed versions available for later editing if needed... since these will have all my comments and easy-to-read formatting.
If a .css or .js file is only needed on a few pages, I only include a compressed version of that file where needed. (and I use the compressed version here too...) But overall, this has proved to be a good strategy for minimizing website overhead - and increasing speed.
TOOLS TO BOOKMARK:
Speed Tests:
http://tools.pingdom.com/fpt/
http://www.selfseo.com/website_speed_test.php
Compression Tools:
http://javascriptcompressor.com/
http://www.cssdrive.com/index.php/main/csscompressor/
Wednesday, May 12, 2010
Finishing up My Own Software
I've never done this before... but on 15 Mar I will have completed my first software for resale.
I have built software for myself before... including a CMS and E-Commerce application. But this is the first time I have completed a software package for public resale. It is a lot of fun.
This bit of software wraps a set of web services and includes data obtained from my personal research. It allows (through IP-detection) the discovery of the visitor's location, timezone, and allows for conversion of date/time to that location's timezone - using that country's preferred date/time displays.
I have built software for myself before... including a CMS and E-Commerce application. But this is the first time I have completed a software package for public resale. It is a lot of fun.
This bit of software wraps a set of web services and includes data obtained from my personal research. It allows (through IP-detection) the discovery of the visitor's location, timezone, and allows for conversion of date/time to that location's timezone - using that country's preferred date/time displays.
Subscribe to:
Posts (Atom)
