Posted by ken zheng on October 10, 2008
The VB language supports the “handles” statement — which allows you to
wire-up the bindings to event handlers on the event handler methods themselves.
Although you can also explicitly wire-up event handlers using the server control
declaration (onclick=”button1_click”), VB developers typically expect/prefer
using the Handles keyword instead.
C# as a language doesn’t have a concept like the “handles” keyword.
Instead, you must explicitly wire-up event definitions.
http://support.microsoft.com/kb/324151
i.e., VB developers can use either method but C# developers must explicitly wireup events.
You may set AutoEventWireup=”true” for VB.Net.
In VS.Net 200x, this means that you can skip the “Handles ….” statement,
provided the method is named correctly.
E.g., if you have AutoEventWireup set to true, this method in a Codebehind file would handle the
Click Event of the Button Control with ID “Button1″ without using onclick=”Button1_Click”
declaratively :
Sub Button1_Click(ByVal s As Object, ByVal e As EventArg)
‘ Look, no Handles
End Sub
If you set AutoEventWireup=”false”, you would need to add the Handles:
Sub Button1_Click(ByVal s As Object, ByVal e As EventArg) Handles Me.Button1.Click
‘ Need Handles
End Sub
C# code:
void Page_Load(Object sender, EventArgs e)
{
// Manually register the event-handling method for the Click
// event of the Button control.
Button1.Click += new EventHandler(this.SubmitBtn_Click);
}
void SubmitBtn_Click(Object sender, EventArgs e)
{
Message.Text=”Hello World!!”;
}
Button Click Example
Click the Submit button.
Here is some good links talk about the AutoEventWireup
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.onclick(VS.71).aspx
http://odetocode.com/Blogs/scott/archive/2006/02/16/2914.aspx
Posted in Uncategorized | 2 Comments »
Posted by ken zheng on October 10, 2008
If you must add server-side code to an .aspx page within your SharePoint environment, then you will need to explicitly tell SharePoint to allow it on the particular page (you can tell SharePoint to allow it on all pages (*), but this is highly discouraged). In fact, if you are able, you should instead deploy your code as a custom user control .
Anyway, to fix this error, all you need to do is add a line to the web.config file under the virtual directory of the Web application. On your MOSS server, open Inetpub > wwwroot > wss > VirtualDirectories > [WebAppName] > web.config.
Find the tag (it will most likely be an empty tag), and add the following line:
Replace “/default.aspx” with the relative path to your .aspx file that has the server-side code. Save the web.config file (this will cause an IIS reset, just FYI). That’s it. Refresh your page and it should be working.
Posted in Sharepoint | 1 Comment »
Posted by ken zheng on October 10, 2008
Below is the function created by Damian Edwards to strips out non-numeric characters, after doing that I can convert to numeric safely (after checking for empty strings and nulls of course):
– Function to strip out non-numeric chars
ALTER FUNCTION dbo.UDF_ParseNumericChars
(
@string VARCHAR(8000)
)
RETURNS VARCHAR(8000)
AS
BEGIN
DECLARE @IncorrectCharLoc SMALLINT
–SET @IncorrectCharLoc = PATINDEX(‘%[^0-9A-Za-z]%’, @string)
SET @IncorrectCharLoc = PATINDEX(‘%[^0-9.]%’, @string)
WHILE @IncorrectCharLoc > 0
BEGIN
SET @string = STUFF(@string, @IncorrectCharLoc, 1, ”)
SET @IncorrectCharLoc = PATINDEX(‘%[^0-9.]%’, @string)
END
SET @string = @string
RETURN @string
END
GO
Posted in SQL | Tagged: TSQL | Leave a Comment »
Posted by ken zheng on October 10, 2008
The recommended approach is to use STSADM -o export to export the site and then to use STSADM -o import to re-import the site afterwards. Alternatively you could set up a content deployment job to deploy the content from one environment to another.
If you do decide to use STSADM -o import to create a new site I recommend that you…
1. Create the Web App in Central Administration.
2. Use STSADM -o createsite to create a blank site collection in the new web application.
3. Use STSADM -o import to import the exported site into the blank site.
Posted in Sharepoint | 1 Comment »
Posted by ken zheng on October 10, 2008
There are two methods of getting around this. In the first method, the administrator goes to all Content Databases (SharePoint Central Admin – Application Management Tab – Content Databases) and takes the databases ‘offline’. Note that simply taking the databases offline does not affect user functionality; it only dissallows new Sites from being created in the specific Content Database. Once all Content Databases except for the one desired are taken offline, creating a new Site Collection will force that Site Collection to be created in the one you want.
If the databases aren’t created in advance, there is an even easier way to do this, by using the –createsiteinnewdb flag with the STSADM tool. The STSADM tool (located on web front-ends in the \program files\common files\microsoft shared\web server extensions\12\bin folder) is a fantastic administrative tool that performs a myriad of administration with SharePoint. In this case, it allows you to create a new Site Collection within a new Content Database. The following Syntax illustrates one example:
stsadm -o createsiteinnewdb -url http://docs.companyabc.com/dept/hr -owneremail SharePoint@companyabc.com -ownerlogin COMPANYABC\SPAdmin -sitetemplate sts -title “Human Resources” -databaseserver SERVER1 -databasename “HR-Content-DB”
In this example, a new site collection is created at the URL http://docs.companyabc.com/dept/hr. The Site Collection Owner is set to COMPANYABC\Spadmin and the Site Collection owner email is set to SharePoint@companyabc.com. The default team site template is used to create the site (the template is simply named ‘sts’, without the quotes.) The database server is SERVER1 and the name of the database created is HR-Content-DB.
Using this concept, you can construct a SharePoint environment that will scale quite nicely, as content is distributed across multiple databases. In addition, If you need to scale to multiple database servers, it simply involves moving content databases to the new server and updating the location in SharePoint.
Posted in Sharepoint | Tagged: Sharepoint 2007, SiteCollection | 7 Comments »