How do I align an image to the right (or left) using HTML?

You can use <img align=”right”> to float a image to the right. (Use align=”left” to float it to the left.) Any content that follows the <img> tag will flow around the image. Use <br clear=”right”> or <br clear=”all”> to mark the end of the text that is to flow around the image, as shown in this example:

The image in this example will float to the right.

<img align=”right” src=… alt=…>

This text will wrap to fill the available space to the left of (and if the text is long enough, below) the image.

<br clear=”right”>

This text will appear below the image, even if there is additional room to its left.

The CSS float property can also be used:

.photo-float-left {
float:left;
margin-right:10px;
}

.photo-float-right {
float:right;
margin-left:5px;
}

ASP.NET and XHTML

Why XHTML ?

XHTML is a World Wide Web Consortium (W3C) standard that defines HTML as an XML document. Creating Web pages that are conformant with XHTML standards has several advantages:

*      It guarantees that the elements in the pages are well formed.
*      Because many browsers are increasingly moving toward supporting XHTML, creating pages that conform to XHTML standards helps ensure that your pages render consistently in all browsers.
*      Using XHTML helps to make pages conform more readily to accessibility standards.
*      XHTML is extensible, allowing the definition of new elements.
*      An XHTML page is much easier to read programmatically for situations in which the Web page is processed by a computer instead of being read by users, and the document can be manipulated using transformations.

http://msdn2.microsoft.com/en-us/library/exc57y7e(vs.80).aspx

This page is specific to Microsoft Visual Studio 2005/.NET Framework 2.0

The W3C has identified several levels of XHTML conformance: XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.0 Strict, and XHTML 1.1. The XHTML 1.1 specification is the strictest of these levels.

For more information about the XHTML standard, see the specification for the Second Edition of XHTML 1.0 on the W3C Web site.(http://www.w3.org/)

How to: Configure XHTML Rendering in ASP.NET Web Sites

By default, when you are working with browsers that support at least HTML 4.0, ASP.NET pages and controls render markup that conforms to the XHTML 1.0 Transitional standard. However, you might want ASP.NET to render markup that conforms to the stricter XHTML 1.0 Strict specification. Conversely, you might want ASP.NET to render markup that does not conform to XHTML 1.0 Transitional specifications. This is typically true when you have existing pages that rely on tags or attributes that were supported in earlier versions of ASP.NET but do not conform to XHTML standards, such as rendering a name attribute in the form tag.

You can configure your Web site to render markup in three ways:

*   Legacy (which is similar to how markup was rendered in previous versions of ASP.NET)
*   Transitional (XHTML 1.0 Transitional)
*   Strict (XHTML 1.0 Strict)

Legacy is for render ASP.NET page markup that does not conform to XHTML, Transitional and Strict are for conforming ASP.NET pages to XHTML

o configure XHTML rendering in an ASP.NET Web site

*
Under the system.web element in your application’s Web.config file, add an xhtmlConformance element, and then set the mode attribute to Legacy, Transitional, or Strict. If no xhtmlConformance element is defined in the Web.config file, the default setting mode is transitional.

The following code example shows part of a Web.config file in which XHTML rendering is disabled.

<system.web>
<!– other elements here –>
<xhtmlConformance
mode=”Legacy” />
</system.web>

The following code example shows part of a Web.config file in which XHTML 1.0 Strict rendering is specified.

<system.web>
<!– other elements here –>
<xhtmlConformance
mode=”Strict” />
</system.web>

—————————————————–
Other ways:

http://www.charon.co.uk/content.aspx?CategoryID=28&ArticleID=53

Redirecting to an ASP.NET Mobile Web Page

(from: http://msdn2.microsoft.com/en-us/library/fhhycabe.aspx)

If you create an application that has one user interface optimized for a desktop browser and a second user interface optimized for mobile applications, you need a mechanism to redirect mobile device customers to the mobile Web pages.

Because some devices do not support cookies, consider whether you want to rely on cookies for your application. For more information, see Controlling Session State.

If your application does not use cookies, you can use the following code in a Microsoft ASP.NET site to redirect to an ASP.NET mobile Web application.

C#
<script runat="server" language="c#">
    public void Page_Load(Object sender, EventArgs e) 
    {
        if (Request.Browser["IsMobileDevice"] == "true" ) 
        {
            Response.Redirect("MobileDefault.aspx");
        }
        else 
        {
            Response.Redirect("DesktopDefault.aspx");
        }
    }
</script>

Because some devices do not accept relative URLs, you must also set the useFullyQualifiedRedirectUrl attribute of the <httpRuntime> element to true in the Web.config file. This sends a fully qualified URL to the client with the session ID appended to the end of the URL. Specifying a relative URL and then converting that URL to a fully qualified URL is necessary to preserve session state. The following example shows the configuration setting.

<configuration>
  <system.web>
    <httpRuntime useFullyQualifiedRedirectUrl = "true" />
  </system.web>
</configuration>

How to change Joomla root URL

If install Joomla on a remote hosting that can install multiple website, you should put all joomla files into a sub-folder, and install joomla database into a seperate database or a new database. and then maybe you have a seperate domain name for your new joomla website. You can setup all steps that just follow  regular steps that multiple websites installed into the same space and add a new domain name to point to your new sub-folder, normally, you should think your new website prepare to work; just one step left: change the root URL of your new website.

Now maybe you just prepare to do like what you did before – access into the database and try to find some field indicate the root URL, but, when you scan all and brower all database, you find you can not find a field store the value of root URL ! strange! where it is ? Joomla doesn’t use database to store its system root URL ?

Yes! Joomla really doesn’t use database store the root URL, it uses config file: in the root of your joomla website, you can find a file named “configuration.php”, open it and you will find the root URL – “$mosConfig_live_site”, change its value to your final root URL.

Done!

Call Client-Side Script

RegisterStartupScript

Using RegisterStartupScript we can write
JavaScript function in code behind and call it from code-behind or from
HTML. Look at the below code for reference.
Calling &amp; writing JavaScript function from server side code behind

private void Page_Load(object sender, System.EventArgs e)
{
string jScriptValidator;
jScriptValidator=”&amp;lt;script&amp;gt; function ReqFieldValidator()” +
” { if (document.forms[0].txtField.value == ”) \n”;
jScriptValidator+=”{ alert(‘TextBox cannot be empty’) \n “;
jScriptValidator+=”return false; \n”;
jScriptValidator+=”} \n”;
jScriptValidator+=” return true \n”;
jScriptValidator+=” } &amp;lt;/script&amp;gt;”;
Page.RegisterStartupScript(“regJSval”,jScriptValidator);
btnSubmit.Attributes.Add(“onclick”,”return ReqFieldValidator()”);

}

Writing JavaScript function in server side code behind and calling from HTML

//Server side
private void Page_Load(object sender, System.EventArgs e)
{
string jScript;
jScript=”&amp;lt;script&amp;gt;function JavScriptFn(){alert” +
” (‘Client Function in javascript is call’)}&amp;lt;/script&amp;gt;”;
}

//HTML side
&amp;lt; A onclick=”JavScriptFn()” &amp;gt;
&amp;lt; asp:Label id=”Label1″ runat=”server” Width=”281px”
ForeColor=”#8080FF”&amp;gt;Click to call Javascript function.
&amp;lt;/asp:Label&amp;gt; &amp;gt;/A &amp;gt;

Writing JavaScript in HTML and calling it from code-behind

&amp;lt;Head &amp;gt;
&amp;lt;script&amp;gt;

function ReqField1Validator()
{
if (document.forms[0].txtField1.value == ”)
{
alert(‘TextBox cannot be empty’)
return false
}
return true
}

&amp;lt;/script&amp;gt;
&amp;lt;/Head &amp;gt;

private void Page_Load(object sender, System.EventArgs e)
{
btnOK.Attributes.Add(“onclick”,”return ReqField1Validator()”);
}

RegisterClientScriptBlock

Suppose
we want JavaScript code to be executed but not a function. In that case
we make use of RegisterClientScriptBlock.RegisterClientScriptBlock
which helps to make server side code as well as client side code inline
to each other.

private void btnClientBlock_Click(object sender, System.EventArgs e)
{
string jScript;
jScript=”&amp;lt;script&amp;gt;alert (‘Javascript block of code executed’)&amp;lt;/script&amp;gt;”;
Page.RegisterClientScriptBlock(“keyClientBlock”,jScript);
lblSequencial.Text=”Remaining part of the code executed”;
}

(from : http://www.codeproject.com/aspnet/ClientServer.asp )

world clock javascript

javascript supporting multiple clocks but not showing the correct GMT time:

<table border=”0″ width=”200″ cellspacing=”0″ cellpadding=”3″>
<form name=”where”>
<tr>
<td width=”100%”>
<select name=”city” size=”1″ onchange=”updateclock(this);”>
<option value=”” selected>Local time</option>
<option value=”0″>London GMT</option>
<option value=”1″>Rome</option>
<option value=”7″>Bangkok</option>
<option value=”8″>Hong Kong</option>
<option value=”9″>Tokyo</option>
<option value=”10″>Sydney</option>
<option value=”12″>Fiji</option>
<option value=”-10″>Hawaii</option>
<option value=”-8″>San Francisco</option>
<option value=”-5″>New York</option>
<option value=”-3″>Buenos Aires</option>
</select>

Call Javascript function from codebehind C#

How to call a javascript function from ASPX.cs code behind file?

Set the Body tag in your page/master page to runat=”server” and an id=”MainBody”.

Put the script tag in your page like you normally would with any HTML file
<script src=”popup.js”  type=”text/javascript”></script>

Then in the code behind attach the onload attribute to the body tag .

protected void Page_Load(object sender, EventArgs e)
{
MasterPageBodyTag = (HtmlGenericControl)Page.Master.FindControl(“MainBody”);
MasterPageBodyTag.Attributes.Add(“Onload”, “Popup()”);
}

Or if you are using Master Pages where the body tag is in the Master Page. but only some of the content pages need to use the javascript.

You put this is the content pages that use the javascript.

protected void Page_Load(object sender, EventArgs e)
{
MasterPageBodyTag = (HtmlGenericControl)Page.Master.FindControl(“MainBody”);
MasterPageBodyTag.Attributes.Add(“Onload”, “Popup()”);
}

Let .NET Mobile Web Application support Javascripts

Is JavaScript supported in Mobile web application ? If yes, How ?

Just give some samples:

in web.config

<
system.web>

<
deviceFilters>

<
filter name=”supportsJavaScript” compare=”Javascript” argument=”true”/>

</
deviceFilters>

</system.web>

in aspx

<mobile:Form ID=”Form1″ Runat=”server”>

<mobile:TextBox ID=”TextBox1″ Runat=”server”>

</mobile:TextBox>

<mobile:Command ID=”Command1″ Runat=”server” OnClick=”Command1_Click”>Command</mobile:Command>

<mobile:Panel ID=”Panel1″ Runat=”server”>

<mobile:DeviceSpecific ID=”DeviceSpecific1″ Runat=”server”>

<Choice Filter=”supportsJavaScript” Xmlns=”http://schemas.microsoft.com/mobile/html32template”>

<ContentTemplate>

<script language=”javascript”>

var control;

control = document.Form1.TextBox1;

control.focus();

</script>

</ContentTemplate>

</Choice>

</mobile:DeviceSpecific>

</mobile:Panel>

</mobile:Form>
check if the device supports javascript?

if (Page.Request.Browser.JavaScript ==
true)

Response.Redirect(
“~/SupportsJava.aspx”);

else

Response.Redirect(“~/NotSupportsJava.aspx”);

( from : http://forums.asp.net/thread/1581990.aspx )

How to prevent a page from being copied ?

How to prevent a page from being copied ?  There are many ways but normally people use blocking the right mouse click function and block text selection function . If the visitor tries to right click mouse and would be ready to select text on your page , he/she will see a error message , or nothing will happen. However, visitor still can get your page content by choosing IE menu item “View \ Page Source” or other else menu item. for this, we can encrypt all page text content, so the visitor can not get the original text page content if he wanna copy via “View \ Page Source”.

Here I found a example from http://www.bluehostforum.com/archive/index.php/t-2796.html. I used it for my this website, my steps are :

1: Create a seperate PHP file named preventCopy.php:


/////////////Encripting code

function _fwk_filter_encryptt($content) {
$table = “0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN OPQRSTUVWXYZ_@”;
$xor = 165;

// Prepare encoding table
$table = array_keys(count_chars($table, 1));
$i_min = min($table);
$i_max = max($table);
for ($c = count($table); $c > 0; $r = mt_rand(0, $c–))
array_splice($table, $r, $c – $r, array_reverse(array_slice($table, $r, $c – $r)));

// Encode sequence
$len = strlen($content);
$word = $shift = 0;
for ($i = 0; $i < $len; $i++)
{
$ch = $xor ^ ord($content[$i]);
$word |= ($ch << $shift);
$shift = ($shift + 2) % 6;
$enc .= chr($table[$word & 0x3F]);
$word >>= 6;
if (!$shift)
{
$enc .= chr($table[$word]);
$word >>= 6;
}
}
if ($shift)
$enc .= chr($table[$word]);

// Decode sequence
$tbl = array_fill($i_min, $i_max – $i_min + 1, 0);
while (list($k,$v) = each($table))
$tbl[$v] = $k;
$tbl = implode(“,”, $tbl);

$fi = “,p=0,s=0,w=0,t=Array({$tbl})”;
$f = “w|=(t[x.charCodeAt(p++)-{$i_min}])<<s;”;
$f .= “if(s){r+=String.fromCharCode({$xor}^w&255);w>>=8;s-=2}else{s=6}”;

// Generate page
$r = “<script language=JavaScript>”;
$r.= “function decrypt_p(x){“;
$r.= “var l=x.length,b=1024,i,j,r{$fi};”;
$r.= “for(j=Math.ceil(l/b);j>0;j–){r=”;for(i=Math.min(l,b);i>0;i–,l–){{$f}}document.write(r)}”;
$r.= “}decrypt_p(\”{$enc}\”)”;
$r.= “</script>”;
return $r;
}

ob_start(“_fwk_filter_encryptt”);

/////COPYRIGHT (No right clic)

echo “<SCRIPT type=\”text/javascript\”>\n”;
echo “<!–\n”;
echo “\n”;
echo “var message=\”Atempting to copy copyrighted content.\”;\n”;
echo “\n”;
echo “///////////////////////////////////\n”;
echo “function clickIE4(){\n”;
echo “if (event.button==2){\n”;
echo “alert(message);\n”;
echo “return false;\n”;
echo “}\n”;
echo “}\n”;
echo “\n”;
echo “function clickNS4(e){\n”;
echo “if (document.layers||document.getElementById&&!document.all){\n”;
echo “if (e.which==2||e.which==3){\n”;
echo “alert(message);\n”;
echo “return false;\n”;
echo “}\n”;
echo “}\n”;
echo “}\n”;
echo “\n”;
echo “if (document.layers){\n”;
echo “document.captureEvents(Event.MOUSEDOWN);\n”;
echo “document.onmousedown=clickNS4;\n”;
echo “}\n”;
echo “else if (document.all&&!document.getElementById){\n”;
echo “document.onmousedown=clickIE4;\n”;
echo “}\n”;
echo “\n”;
echo “document.oncontextmenu=new Function(\”alert(message);return false\”)\n”;
echo “\n”;
echo “//–>\n”;
echo “</SCRIPT>\n\n”;

//////Dont allow to select text

echo “<SCRIPT type=\”text/javascript\”>\n”;
echo “<!–\n”;
echo “\n”;
echo “function disableselect(e){\n”;
echo “return false\n”;
echo “}\n”;
echo “\n”;
echo “function reEnable(){\n”;
echo “return true\n”;
echo “}\n”;
echo “\n”;
echo “//if IE4+\n”;
echo “document.onselectstart=new Function (\”return false\”)\n”;
echo “\n”;
echo “//if NS6\n”;
echo “if (window.sidebar){\n”;
echo “document.onmousedown=disableselect\n”;
echo “document.onclick=reEnable\n”;
echo “}\n”;
echo “//–>\n”;
echo “</SCRIPT>\n\n”;

2: Open my template folder and open index.php:

insert in the index.php, add at the beginning:

<?php
include(“preventCopy.php”);
?>

Actually my index.php :

<?php
//写中文为了存utf8
defined( ‘_VALID_MOS’ ) or die( ‘Direct Access to this location is not allowed.’ );
// needed to seperate the ISO number from the language file constant _ISO
$iso = explode( ‘=’, _ISO );
// xml prolog
echo ‘<?xml version=”1.0″ encoding=”‘. $iso[1] .'”?’ .’>’;

include(“preventCopy.php”);

?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
….

But, since my website is using UTF-8 encoding, this preventCopy.php is just for ISO-8859-1, so I can not use  “Encripting code” part, I have to comment out this part just keep right click bloking and select function blocking.