Cyberactiva WEB

Thursday, March 6, 2008

EASY REGULAR EXPRESSIONS IN C#

I really love using regular expressions.
It's so easy to check strings... for example if you want only alphanumeric or only numbers or a very specific format like two letters, one point, one number and a #, in the specific order.
In my opinion, it's highly difficult to create the reg exp from scratch.
I have found a very good shareware program which build and test them for me. You can find it here.

Once you have your regular expression, how can you use it in your code?
Let's say you just need to check if a string is composed only by alphanumeric chars.

Here's a bit of C# code:

string mystring = "HELLO";
string regExpString = "^\\w+$";


if (System.Text.RegularExpressions.Regex.IsMatch( mystring , regExpString))
//here mystring contains only alphanumerics
else
// here mystring contains also something else


So... isn't it easy?

Tuesday, February 26, 2008

SHAREPOINT: One of more field types are not installed properly

If you get this error while debugging your Sharepoint application, you have probably to know that you must call the fields with their INTERNAL NAME, which can be different from the name you see on labels on the site.

How can you find the correct internal name?
You can go to a page in which you have the possibility to edit all the fields and then look in the page source for the fieldname; otherwise you can also order a view by the specific field and then see what is written in the url.

I got this problem while trying to use the method UpdateListItems
in the lists.asmx Sharepoint webservices.
Here is the code I used:

XmlDocument doc = new XmlDocument();
XmlElement newFile = doc.CreateElement("Batch");
newFile.SetAttribute("OnError", "Return");

// as field name, we must pass the INTERNAL NAMES of the fields, example: Title is the internal name of the field Subject

newFile.InnerXml = "" +
"New" +
"" + NewName + "" + // Title is the internal name of Subject
"" + _client + "" +
"" + _listtype + "" + //internal name of List type
"" + _country + "" +
"" + _datext + "" +
"
";
XmlNode returnValue = WS.UpdateListItems("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", newFile);


Hope this will help you!

Labels:

Sunday, February 24, 2008

NEW 2008 LAYOUT AND PLATFORM

This is the new layout of Cyberactiva.
At last I have decided to move towards a standard platform (Blogger), after many years spent to continuosly update my old selfmade platform. This is not a defeat, actually.
When I started publishing articles on the web, five years ago, I wasn't satisfied with any of the CMS on the open source market... and I didn't want to spend money to buy any. So I just extended a product I developed for a client.
I am not selling CMS anymore and so I had no time to update it with all the new features that everybody can find for free on Blogger or on Wordpress, just to mention the most known.
If you are interested in old articles, here you can find older messages about WEB MARKETING and here about WEB PROGRAMMING.

Visual web developer: compile and publish your web site

Visual web developer is a very good free environment to develope web projects over the .NET 2.0 framework.
Everything works fine, developing is great, debugging much better than in visual studio 2003.
The problem comes when you need to publish the web site. This option is not available on visual web developer. It is available only in Visual Studio 2005.
You could just copy all source files on the server, and they will be compiled run-time; anyway it is not recommendable to distribute source file, I mean for business reasons.
The alternative is to open the command console and launch the following command:

aspnet_compiler -p C:\MyWebSite -v / C:\Staging

This should produce the DLL to copy on the server.

Labels:

SHAREPOINT:The list that is referenced here no longer exists

Are you get this error while using the updatelistitems method in SHAREPOINT web service (list.asmx)?
Are you aiming to data stored in a subsite?
If so, the solution is to point the webservice of the subsite directly.
If your main site is http://cia, and your subsite is http://cia/coa, you should point to the webservice:

http://cia/coa/_vti_bin/list.asmx

Pay attention that, sometimes, when you update the webreference, in the app.config it remains the same. So change it there as well.

Good luck!

Labels: