July 2009 - Posts

Telerik Upload Control Inside Rad TabStrip

 i've been 3hours working on this.

You see every control that you put under the tabstrip, multipage

is ajax by default. so that every button that should post back, is not full post back instead using ajax call.

to avoid this we can temporarily disabled it.

 // on upload button click temporarily disables ajax to perform
   // upload actions
   function conditionalPostback(sender, args)
      if (args.get_eventTarget() == "
<%= ButtonSubmit.UniqueID %>")


Wrap the control that you want to behave post back as usual by Wrap it under

<telerik:ajaxpanel ClientEvents-Onrequeststart="conditionalpostback">

You control here the button submit and Rad Upload



And then if the Upload always resulting on the FileCount is 0 on Submit

It's because on masterpage Init you change the id or something

So you should disabled or not using master page

or find the control/code that change it


Share this post: | | | |
Posted by cipto with no comments
Filed under:

Document Fragment Isolate them Self , Style or css is missing

I've been doing this xml and xslt transormation on client side a.k.a javascript

And to my suprise altough i use the xslt.js or built in function for transormation

When you do an apped child , the Css that is tag with the result is not showing

So what ever css you put there inline, or class name ...

it's not showing

Damn....... This happen on FF,Safari and Opera. with xslt.js you get it right on ff , IE only.

Apperantly the result got back is DocumentFragment.

Document Fragment Is Isolating it self, so it's like a lighweight live instantiate Element. But will not Followed what ever css you put in.


Anyway i found out solution , is to chaneg the DocumentFragment type Xml  To String again

var xmlString = (new XMLSerializer()).serializeToString(resultDoc);

and as usual set the div.innerHTML = xmlString.


I give up using xslt on client, It always different on IE, FF , Safari throw error, opera buggy

Yaiks. i use the server side

Share this post: | | | |
Posted by cipto with no comments
Filed under:

How to make dynamic css and theme

To make a Theme Changing Programatically

you need to set the Page.theme on preinit event of a Page.

Make a base class that override the preinint and your logical of changing theme.


Use this event for the following:

  • Check the IsPostBack property to determine whether this is the first time the page is being processed.

  • Create or re-create dynamic controls.

  • Set a master page dynamically.

  • Set the Theme property dynamically.

  • Read or set profile property values.

    If the request is a postback, the values of the controls have not yet been restored from view state. If you set a control property at this stage, its value might be overwritten in the next event

And then how to make dynamic css? just make a ashx which content type = text/css

finally how to Override the css from the App_Theme, which will generate pattern like app_them234234.css

you can add another link to the page by using page.header.add("<link string..");


Share this post: | | | |
Posted by cipto with no comments
Filed under:

Wrap Text with Pre

there are a way to wrap text in a certain width , and automatically goes down.

note :word-break:break all -> only works on IE.

with out table cell wrap your text with pre.. and you still can have the style also not like those text area.

but beware of the  /t character in your text , it will indent very deep .

So the solution is using pre abut eliminate the tab character. there you have a wrap text

and then adjust the over flow text container/div height . with javascript  .scrollheight


Share this post: | | | |
Posted by cipto with no comments
Filed under:

Full Text Search/Indexing

if you are implementing a search on your web application.and you want to query or search but not the physical path or pages, you want to search what is contained or data on your database.

then this fulltext search feature is already there since sql server 7 i think.

So instead you do a search with " Like %something%" , which will trigger the whole table scan for that . imagine you have many users and dependful on search. ex: like what i'm building now, public tracker site. it will bloat the server memory just to serve the search


The full text run on another services, which will Crawl your table and build your indexes. When a search is there it serves from the indexes.

there are also few word like contains, freetext, containstable,freetexttable.


The table ones you can inner join the result with. 

and also if you want to make a query that will search 'LIKE %something%' 


you should declare variable before passing to contains(param) it will make error believe me.


DECLARE @temp varchar(250)
set @temp= '"*' + @word + '*"'


Something T
CONTAINSTABLE(Torrent, *,@temp ) AS SomethingResults
ON T.ID= SomethingResults
Type on T.TypeID=[Type].TypeID

To check population Status:

 --check populate status
/*0 = Idle

1 = Full population in progress

2 = Paused

3 = Throttled

4 = Recovering

5 = Shutdown

6 = Incremental population in progress

7 = Building index

8 = Disk is full. Paused.

9 = Change tracking
SELECT fulltextcatalogproperty('TradixFullTEXT', 'PopulateStatus');

--check how many  item currently on index
SELECT fulltextcatalogproperty('TradixFullTEXT', 'ItemCount');

To force update population from query :



 Enable Fulltext on DB

EXEC sp_fulltext_database 'enable' 

 Check fullText is enabled or not

SELECT DATABASEPROPERTY('databasename', 'IsFullTextEnabled');

Check full text index Status

select * from sys.fulltext_indexes Table_Name

Once you 've added it . you can scheduled it as you wish . like occuring every day, at what time, every hour and so on

just right click on the table->fulltextindex->Schedule. Than change what ever we like it's adding job to sql server agent . and definitely this feature is not included on sql express.. because express does not have sql server agent.



Share this post: | | | |
Posted by cipto with no comments
Filed under:

How to make a Private Bittorent Tracker

After I've got an email from Alan mcgorven and a  Link, Alan is the maker of monotorrent which a.k.a Bitsharp on mono, it becomes clearer for me the path to make a private tracker

How we can make a tracker private is by Embedding a key , a query string on the announce url :

"Basically when you create the torrent, just append a secret key to the end of the announce url. I'll use the username in my example:

Regular Announce Url:

Joe's announce url:


Bob's announce url:

Then, whenever a request is received by the tracker, you first check that the 'pass' key has been supplied in the query string then you check that the value of it is valid, i.e. you do have a user called joe or bob. If that check passes, then you can call the Handle () method and process the request. If the check fails, don't call the Handle () method, but return an error message instead.

The easiest way to accomplish this is to store an unmodifed .torrent file on your server and provide a download link. When a user clicks the link, load the .torrent file into memory in it's raw form (a BEncodedDictionary), alter the announceurls by appending the key, then just call bencodedDictionary.Encode () to convert to a byte[] and send that to the user."
Here is the Working code on Asp.net that i make To Generate the torrentfile, please do combinate this with encrypted the key, the key can be anything you think of , save to db and the tracker should check it.
   string filepath = context.Request.Form["txtfilepath"];
   System.IO.StreamReader reader = new StreamReader(@filepath, true);
   MonoTorrent.BEncoding.RawReader BitTorrentReader = new RawReader(reader.BaseStream);
   BEncodedDictionary RawContent = BEncodedDictionary.DecodeTorrent(BitTorrentReader);

   BEncodedValue annouceurl;
   RawContent.TryGetValue("announce", out annouceurl);

   string x = annouceurl.ToString();
   x += "?key=somekey";
   BEncodedString mynewstring = x;
   RawContent["announce"] = mynewstring;
   context.Response.ContentType = "application/x-bittorrent";


Fix the Mono Torrent Why not Triggering Scrape Feature.

It's because on the HTTP listener only add prefix of http://{0}:{1}/announce/", address, port

Changed on Listeners-> HttpListener.cs

  private List<string> prefixes=new List<string>();

  public HttpListener(IPAddress address, int port)
            : this(string.Format("http://{0}:{1}/announce/", address, port))
            AddPrefix(string.Format("http://{0}:{1}/scrape/", address, port));
 private void AddPrefix(string httpPrefix)

 to get the Tracker statistic  .we make what to watch by implementing ITrackable

we access it from the TorrenManager.

So if it's from sample project should be:

                 foreach (SimpleTorrentManager m in tracker)
                    Console.Write("Name: {0}   ", m.Trackable.Name);
                    Console.WriteLine("Complete: {1}   Incomplete: {2}   Downloaded: {0}", m.Downloaded, m.Complete, m.Incomplete);


For the pass KEY , we can add another query string it doesn't have to be key=something, we can named it with another one ex: passkey=something

because bit torent client already append a generated key to key. so if you insert something it will be  key=something,DDFD where DDFD ex: is the generatedkey from utorrent/bitcommet

13th July 2009

I've updated the tracker which is httplistener to use prefixes http://*:port/announce, some times if a computer has a lot of ip or network card.  A Start '*' means

Listen to every of those ip , On this port. There you go it's running on the server now



Share this post: | | | |
Posted by cipto with no comments
Filed under: