It may seem an obvious question: Which to choose Code Snippet Action Item or C# Snippet Action Item (obsolete). The latter clearly says obsolete — so why would you use it? Why is it still included?
The answer is not so simple. Could it be removed? Perhaps, but there are cases when it is necessary. Let’s cover the differences first.
The Code Snippet Action items are compiled into a dll. This dll is then placed into the bin directory of the deployed portal. This is nice for you because you can use an external dll, vb.net, or C# to code. It does raise a problem though. The dll does not have direct access to the page. This means if the code in the dll needs to interact with the form — let’s say update a textbox — it needs to do so through the form object that is passed into it. It cannot talk directly to the textbox. This is also its major benefit by the way, but we can talk about that in a bit.
So the C# Snippet Action Item DOES have direct access to the form right? Right. The code you write in a C# Snippet Action Item actually gets placed onto the form itself. It is IN the aspx page. You can see it there. You can edit that file in notepad (I like notepad++ myself) and then refresh your browser and see the changes. That makes for some fast development. So why is it obsolete? It is faster and easier! Hold on for a minute.
The Code Snippet Action Item makes you go through the form to access the controls on the form. This means that you are accessing the SLX controls through the form and through that interface. The C# Snippet Action Item talks with the .NET version of the control. Anything that the SalesLogix developers did not implement in the SalesLogix version of a TextBox will not be exposed through the form. I talked about this last week here: http://slxtraining.net/2009/10/new-form-control-in-saleslogix-7-5-2-sp2/ . This means if they left something off, perhaps a new feature or something more obscure — you have to do something extra to get to it. Not too bad. The C# Snippet Action Item can interact with the page directly and therefore can do a bit more. This is certain to be true.
So I am not convincing anyone that the C# Snippet Action Item should be marked as obsolete am I?
Consider when the platform you are deploying to changes. Perhaps you are deploying to the web now and later also to a smartphone portal. You may have a slightly different TextBox control in that deployment — it will likely be a bit more limited and not implement .Text but instead .Value. If you are writing code that ends up on the page itself you would have to write code to check for the deployment and capabilities of the deployed platform. That will not be fun to check for .Text or .Value each and every time.
If you use the Code Snippet Action item and work through the SalesLogix TextBox control this work will be done for you. This means you code for TextBox.Text and you do not worry about the platform changes so much. For this same reason you should avoid getting to the NativeControl when in a Code Snippet Action item. The SalesLogix developers take your code and write it up in a dll for the target platform. You write the code once and the build process works for you.
So the C# Snippet Action Item is obsolete because it should no longer be needed and can actually cause future deployment issues. It is that simple. It is that simple to NOT use it? Not yet. There are still very few cases when it is needed, but by default you should be choosing Code Snippet Action Item.



