Thursday, February 21, 2008

FreeTextBox

Very Good Editor to get what you see...

website:http://freetextbox.com/

Here are some important points to remember when using the Image Gallery control with the Freetextbox, in ASP.NET.
The image gallery control that is packed with the Freetext box control has some significant functionality that we could use instead of spending time to develop the Image uploads, resizing retaining its resolutions and maintaining your own image gallery in a web application. Freetext box, gives you facility of editing some content and save with its formatting. What it saves is basically HTML.

First you should download the Freetext box control from http://www.FreeTextbox.com/ site and add the control to the Tools. Then double click on the Freetext box and add the control to your web page.

Set the Validate Request of the ASPX page to false on the page directive.

ValidateRequest="false"

By default in ASPX pages the RequestValidation is set to true to avoid un-encoded HTML content being submitted to the server. But we will set this status false, since we need to send HTML to the server.

Now lets add the Image Gallery to this Freetextbox. Go to the folder that you downloaded and Freetextbox ->examples ->fullyloaded->ftb.imagegallery.aspx and add this to your web application.

Under the Freetextbox properties Click on ToolbarLayout property, and copy the following.

ParagraphMenu,FontFacesMenu,FontSizesMenu,

FontForeColorsMenuBold,Italic,Underline,Strikethrough;Superscript,

Subscript,RemoveFormatJustifyLeft,JustifyRight,JustifyCenter,

JustifyFull;BulletedList,NumberedList,Indent,Outdent;CreateLink,

Unlink,InsertImage,InsertRuleCut,Copy,Paste;Undo,Redo,

Print,InsertImageFromGallery,Preview,

SelectAll,WordClean,NetSpell


The ToolbarLayout property will contain the functionality of the Freetextbox and the blue colored parts indicated the image gallery functionalities, that we added newly.

Now we need to set some properties as to Create folders, Upload Images, Delete Images and etc, so click on the ftb.imagegallery.aspx and in the code find where it references the freetextbox and set the following properties.

AllowImageDelete="true" AllowImageUpload="true" AllowDirectoryCreate="true" AllowDirectoryDelete="true" runat="Server" />

One significant point is that by default all the images are saved in the "images" folder in your application and any directory we create will also be created in side the "images" folder. There fore its a point to remember that if your site uses any other images that you do not require user involvements (such as images in banners or buttons) better place then in a separate folder, and create a folder with the name of "images" inside your web application.

If you user master pages then there is a small change you need to do in the ftb.imagegallery.aspx. Make the header part runat server.



Image Gallery



Freetextbox is used as to allow the user to have the flexibility to design the content as he wishes, there for the length of the text we need to store would be a problem there for by using a data type "text" in the SQL server would give the facility to store enough text as requests.

Now that all are done lets take a look at how it appears.

Fckeditor Integration ASPNet

Chinese: http://ajunlee.pbwiki.com/FckeditorIntegrationASPNet

English : http://wiki.fckeditor.net/Developer%27s_Guide/Integration/ASP.Net

boot.ini error

"Invalid Boot.ini" or "Windows could not start" error messages when you start your computer

Article ID : 330184
Last Review : May 7, 2007
Revision : 2.2

This article was previously published under Q330184
SYMPTOMS
When you start your computer after you upgrade to Microsoft Windows XP, you may receive one or both of the following error messages:
Invalid Boot.ini
Windows could not start because the following file is missing or corrupt:

Windows\System32\Hal.dll
Back to the top

CAUSE
This issue may occur if the Boot.ini file is missing, damaged, or contains incorrect entries.
Back to the top

RESOLUTION
To resolve this issue, start the computer from the Windows XP CD, start the Recovery Console, and then use the Bootcfg.exe tool to rebuild the Boot.ini file. To do this, follow these steps: 1. Configure the computer to start from the CD-ROM or DVD-ROM drive. For information about how to do this, see your computer documentation, or contact your computer manufacturer.
2. Insert the Windows XP CD-ROM into your CD-ROM or DVD-ROM drive, and then restart your computer.
3. When you receive the "Press any key to boot from CD" message, press a key to start your computer from the Windows XP CD-ROM.
4. When you receive the "Welcome to Setup" message, press R to start the Recovery Console.
5. If you have a dual-boot or multiple-boot computer, select the installation that you have to use from the Recovery Console.
6. When you are prompted, type the administrator password, and then press ENTER.
7. At the command prompt, type bootcfg /list, and then press ENTER. The entries in your current Boot.ini file appear on the screen.
8. At the command prompt, type bootcfg /rebuild, and then press ENTER. This command scans the hard disks of the computer for Windows XP, Microsoft Windows 2000, or Microsoft Windows NT installations, and then displays the results. Follow the instructions that appear on the screen to add the Windows installations to the Boot.ini file. For example, follow these steps to add a Windows XP installation to the Boot.ini file: a. When you receive a message that is similar to the following message, press Y:
Total Identified Windows Installs: 1

[1] C:\Windows
Add installation to boot list? (Yes/No/All)
b. You receive a message that is similar to the following message:
Enter Load Identifier
This is the name of the operating system. When you receive this message, type the name of your operating system, and then press ENTER. This is either Microsoft Windows XP Professional or Microsoft Windows XP Home Edition.
c. You receive a message that is similar to the following:
Enter OS Load options
When you receive this message, type /fastdetect, and then press ENTER.

Note The instructions that appear on your screen may be different, depending on the configuration of your computer.

9. Type exit, and then press ENTER to quit Recovery Console. Your computer restarts, and the updated boot list appears when you receive the "Please select the operating system to start" message.

How to drop all tables in Oracle

Written by coregps on December 6th, 2006 in Oracle.




We sometimes need to drop all tables in Oracle. If there are many tables in the database, it will be a terrible work. The easiest way is to write a simple small SQL*Plus script to retrieve all tables of a specified user and generate DROP statements. It is something look like this:

SQL> spool c:\drop_tables.sql
SQL> SELECT ‘DROP TABLE ‘ || table_name || ‘ CASCADE CONSTRAINTS;’ FROM user_tables;
SQL> spool off
Then we can execute the generated script “drop_tables.sql” like following:

SQL> @c:\drop_tables.sql
But be careful! Be sure to log on as the correct user!

If we login as sys or system, we can run this script:

spool c:\drop_all_tables.sql
select “drop table ” || table_name || ” cascade constraints;” from all_tables where owner = ‘User Name’
spool off

MySQL Reconfiguration problems.

MySQL has some bugs, may be a bug, i am not sure, may be my wrong configuration.

if do reconfig, it will get error during excuting the details, actually in starting the service.

after do some research, i found a related answer as below. in today's case, it should be the old entries still in the registry.

Obviously there are some bugs, which might interact with each other:
a) Pathnames, as proposed, with included blanks (and probably dots, etc).
b) A security/acl issue when trying to alter the security settings.
c) When there a old entries in the registry...

Hopefully, somebody of MySQL AB will recognise this to be a problem, since this is a annoying bug. The follwing receipt helped me on both 'essential' versons, MySQL Vs. 4.1.9 and 5.0.2, respectively.

Hope, it helps! ... regards, A.N.


Gary Williams wrote:
> Hi Guys,
>
> I've had exactly the same problem and this is how
> I got it working for me, starting with a non
> working installation.
>
> 1. Stop the windows service for any existing mysql
> installation.
>
> 2. Uninstall Mysql.
>
> As with most uninstalls, old files are left
> behind. If your directory is C:\mysql\ etc then
> delete the innob, etc, files but leave the
> directories themselves as well as any existing
> databases in 'data'. If your directory is
> C:\Program Files\ etc, delete all the mysql
> directories.
>
> 3. It's now worth running regedit to make sure
> the old registry entries are deleted as well by
> the uninstall. If not, delete them.
>
> 4. It's ok to use the new .msi installer
> (essential files only), however ....
>
> 5. Do not use their default install path! Some
> genius set a path with spaces in it! Choose the
> custom install and select a sensible path, ie,
> C:\mysql
>
> 6. Do not choose to alter the security settings.
> Uncheck the relevant box and the install will
> complete without having to set a root password.
>
> I think I have remembered everything.
>
> Good luck
>
> Gary

Invalid postback or callback argument

每次 request 還沒來得急接收到 response 就又再點其它按鈕),會發生 Invalid postback or callback argument 錯誤:

Invalid postback or callback argument. Event validation is enabled using
in configuration or <%@ Page
EnableEventValidation="true" %> in a page. For security purposes, this
feature verifies that arguments to postback or callback events originate
from the server control that originally rendered them. If the data is valid
and expected, use the ClientScriptManager.RegisterForEventValidation method
in order to register the postback or callback data for validation.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Solution:

if you created a sub procedure that populates your
datalist and you are calling it when the user clicks a button within
your itemtemplate, after the data processing has been done (or whatever
processing you're doing with that button), make sure that it isn't also
being called in your Page_load sub. When your page FIRST loads and you
populate the datalist control, make sure that you have it within a If
Not Page.IsPostBack and not where it gets called on every load.

Upload Video in asp.net

First of all, by default, asp.net set the size is 4mb for each form request...if u want to upload larger file, u need to change the setting in web.config.

adding
between .

maxRequestLength is the maximum size of each form request
requestLengthDiskThreshold is the buffer size in server memory

before i didn't set executionTimeout, so the asp.net kills every request takes longer than 110seconds. so every time i upload the file takes longer than 2mins , it will comes up a not found page.....
set executionTimeout to allow the request time how long u want in seconds.

this method suppose is not good in uploading large files, it will spend all the server memory during upload progress. but in my project, there is only one person to upload the file, so it will not affect too much. But if so many people upload like youtube, hv to set sth like httphandle.....but i hvn't learn this, i think quite hard. btw, there is some control developed by company in order to handle this situation like PowUpload and KUpload. but not free.

then just use the control of FileUpload of asp.net.
and code:

aspx source:



code behind:
private bool CheckFileType(string fileName)
{
string ext = Path.GetExtension(fileName);
switch (ext.ToLower())
{
case ".rmvb":
return false;
default:
return true;
}
}
private void initialDataList()
{
string upFolder = MapPath("~/Video/VideoFiles/");
DirectoryInfo dir = new DirectoryInfo(upFolder);
DataList1.DataSource = dir.GetFiles();
DataList1.DataBind();
}
protected void Page_Load(object sender, EventArgs e)
{
initialDataList();
}
protected void btnAddVideo_Click(object sender, EventArgs e)
{
if (upVideo.HasFile)
{
if (CheckFileType(upVideo.FileName))
{
string filePath = "~/Video/VideoFiles/" + upVideo.FileName;
upVideo.SaveAs(MapPath(filePath));
}
}
initialDataList();
}

Load WebUserControl programmatically and Print it using session

Control _myControl;
protected void Page_Load(object sender, EventArgs e)
{
_myControl = LoadControl("SubContent1.ascx");
Arlyia_SubContent1 _subContent = (Arlyia_SubContent1)_myControl;
_subContent.XmlDataSourceXPath = "contents/content[@name='MainContent1']/subcontent[@name='SubContent1']/htmlcode[@language='"+Session["language"].ToString()+"']";
PlaceHolder1.Controls.Clear();
PlaceHolder1.Controls.Add(_myControl);
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
Session["ControlsToPrint"] = _myControl;
//Response.Write("var printWindow = window.open('PrintWindow.aspx', 'PrintWindow'," + "'toolbars=no,status=no,width=300,top=10,left=10,height=300,resizable=no,scrollbars=no,menubar=no');");

//Control _myPrintingPageControl = LoadControl("~/PrintingPage/PrintingPageControl.ascx");
//PrintingPage_PrintingPageControl _printingPage = (PrintingPage_PrintingPageControl)_myPrintingPageControl;

//_printingPage.MyControl = _myControl;

//_printingPage.Page.RegisterClientScriptBlock("", "");

//PlaceHolder2.Controls.Add(_myPrintingPageControl);

//TextBox a = (TextBox)_printingPage.FindControl("TextBox1");
//a.Text = "shit";

Page.RegisterClientScriptBlock("", "");

//PlaceHolder bb = (PlaceHolder)_printingPage.FindControl("PlaceHoder1");
//bb = PlaceHolder1;

//Response.Write(bb.Controls[0].ToString());

//PlaceHolder bb = (PlaceHolder)_printingPage.FindControl("PlaceHoder1");
//bb.Controls.Add(a);
//Response.Redirect("~/PrintingPage/PrintingPage.aspx");
//_myControl.PlaceHoder.Controls.Add(a);
}

edit xml in xmldatasource

edit xml in xmldatasource

protected void Page_Load(object sender, EventArgs e)
{
//UpdatableXmlDataSource1.FilterXPath = "contents/content[@position='test']/htmlcode[@language='english']";
XmlDataSource1.XPath = "contents/content[@position='test']/htmlcode[@language='english']";
}
protected void Button1_Click(object sender, EventArgs e)
{
XmlNode node = XmlDataSource1.GetXmlDocument().SelectSingleNode("contents/content[@position='test']/htmlcode[@language='english']");
node.InnerText = "hihi";
XmlDataSource1.Save();
}

Retrieve the Html code for a Web User Control

public static string GetHtmlForControl(Control control)
{
StringWriter textwriter = new StringWriter();
HtmlTextWriter writer = new HtmlTextWriter(textwriter);

control.DataBind();
control.RenderControl(writer);
string html = textwriter.GetStringBuilder().ToString();

return html;
}

Tip: If you're having problems with the generated Html being incomplete, then maybe you're calling the function above in the wrong time? I've been having some problems with databound EPiServer controls until we discovered that we were doing this too early. When we started doing it in the PreRenderComplete event of the page, then it started working:

protected void Page_PreRenderComplete(object sender, EventArgs e)
{
string html = FormHelper.GetHtmlForControl(Butikshuvud);
}

ASP.NET 2.0 Treeview - Expanding Nodes when Bound to SiteMap

The problem

A treenode can be selected or expanded. Selecting the node causes the SelectedNodeChange event to fire if the Treeview is configured correctly. Clicking the + icon on a node causes the TreeNodeExpanded event to fire. The selected event will not fire if the node is in Navigation mode. This behavior makes sense most of the time. The node is acting as a navigation link - it causes the browser to take you to a new page which means there is no postback. Your are going to a new page, without returning to the server first.

If the node has its NavigationUrl property set to an empty string, the node is in Selection mode. If the NavigationUrl is a non-zero length string ,the node is in Navigation mode.

For our project I wanted the children nodes to expand whenever the user selects a parent node. Yes, the user can click the + symbol to expand it, but our testing showed that many users expect the node to expand by clicking the node text instead. Since the nodes are in Navigation mode I couldn't put the code in the SelectedNodeChanged event.

My solution? Use the TreeNodeDatabound event to examine each node as it is being bound to the tree. If the current page URL matches the treenode NavigationUrl I expand all the of the current nodes children. It solves my problem. It still doesn't cause the SelectedNodeChanged to fire so it may not solve all your troubles. At least it's a start.

Protected Sub treeMainMenu_TreeNodeDataBound _
(
ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs) _
Handles treeMainMenu.TreeNodeDataBound

' other binding code here...

If Request.Url.PathAndQuery = e.Node.NavigateUrl Then
e.Node.ExpandAll()
End If
End Sub