ÈÃASP.Net HTMLÒ³Ãæ´úÂë ÇåˬÆðÀ´
×Ô´ÓÓÃÁË ASP.Net MVCºó¾Íϲ»¶ÉÏÁËËü £¬ÒòΪMVC¶Ô·þÎñÆ÷¿Ø¼þµÄÒÀÀµ´ó´ó¼õÉÙ£¬ËüÉú³ÉµÄHTMLÒ³Ãæ¾Í±ÈWebFormÇåˬ¶àÁË£¬¼ÓÔØËÙ¶ÈÓÐÁËÃ÷ÏԵĸÄÉÆ¡£
µ«¶ÔÓÚÒ³ÃæÖÐÄÚǶscript£¬»¹ÊDz»Äܳ¹µ×µÄ±ÜÃ⣬È磺
<script type="text/javascript" language="javascript">
//<!--
function DepositPage() {
// ÕâÊÇÒ»¸öµÚ3·½µÄWebControl,ÓÉÓÚÊÇ·þÎñÆ÷¿Ø¼þ£¬ÊÜMasterPageÓ°Ïì,ËüµÄ¿Í»§¶ËID²¢²»ÊÇÈ·¶¨µÄ¡£
this.ctrlRadGrid = "#<%= ctrlRadGrid.ClientID %>";
// ÕâÊÇÒ»¶ÎÓÖ³ôÓÖ³¤µÄJSON£¬´ÓModalÖд«µÝ¹ýÀ´
this.accounts = <%= Modal.JSON %>;
// .............................
}
new DepositPage();
// -->
</script>
ÊÇ·ñÓÐÒ»ÖÖ·½·¨¿ÉÒÔ½«Õâ¶ÎJS²»ÄÚǶÔÚHTMLÖУ¬Ê¹ÓÃ<script src="">±ê¼Ç´ÓÍⲿÎļþ¼ÓÔØ?
´ð°¸Êǿ϶¨µÄ£¬Í¨¹ý×Ô¶¨ÒåWebControlÍêÈ«¿ÉÒÔʵÏÖ£¬ÓÐÈçÏÂWebControl
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
[ParseChildren(false)]
public class ExternalJavascriptControl : WebControl
{
private string SafeFilenamePrefix
{
get
{
return Regex.Replace( this.ClientID
, "(\\\\|\\/|\\:|\\*|\\?|\\\"|\\<|\\>|\\|)"
, "_"
, RegexOptions.ECMAScript | RegexOptions.Compiled
);
}
}
protected override void Render(HtmlTextWriter writer)
{
if (!Visible)
return;
try
{
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter htw = new HtmlTextWriter(sw))
{
base.Render(htw);
// get the rendered content
string rendered = sw.ToString();
// remove the script tag if exist
rendered = Regex.Replace(rendered
, @"(<[\s\/]*script\b[^>]*>)"
, string.Empty
, RegexOptions.ECMAScript | RegexOptions.Compiled | RegexOptions.IgnoreCase
);
// get the file pa
Ïà¹ØÎĵµ£º
·þÎñÆ÷¶Ë½Å±¾¿é£º
<script runat="server">
int my = 10;
</script>
·ÖÉ¢µÄ½Å±¾
<%= my.ToString() %>
<% Response.Write(my); %>
.aspxÎļþµÄÄÚÈݱ»½âÎöÎ ......
ËÆË®Á÷Ä걨¸æÁËASP.NET MVC 2 Õýʽ·¢²¼£¬ÄÇôÎÒÃÇÓÐÐí¶àASP.NET MVC 1.0µÄ³ÌÐòÐèÒªÒÆÖ²µ½2.0Ôõô°ìÄØ£¿Eilon Lipton ÒѾ·¢²¼ÁËһƪ²©ÎÄ migration tool for converting ASP.NET MVC 1 application projects£¬ÎªÎÒÃǵÄVisual Studio 2008µÄMVCÏîÄ¿µÄÇ¨ÒÆ×¼±¸ºÃ¹¤¾ß£¬Ö÷Òª¹¤×÷¾ÍÊÇת»¯ÏîÄ¿ÀàÐÍ£¬¸üгÌÐò¼¯µÄÒýÓúÍÉú³ÉÅäÖÃÐ ......
1. web.config
<connectionStrings>
<add name ="myconn" connectionString="Data Source=who\SQLEXPRESS; Initial Catalog=dbname;Integrated Security=True;" providerName="System.Data.SqlClient"/>
</connectionStrings>
2.
string htmlPath = "D:\\htmlFiles";
......
Ò»).´´½¨²¿ÊðÏîÄ¿
1. ÔÚ“Îļþ”²Ëµ¥ÉÏÖ¸Ïò“Ìí¼ÓÏîÄ¿”£¬È»ºóÑ¡Ôñ“н¨ÏîÄ¿”¡£
2. ÔÚ“Ìí¼ÓÐÂÏîÄ¿”¶Ô»°¿òÖУ¬Ñ¡Ôñ“ÏîÄ¿ÀàÐÍ”´°¸ñÖеē°²×°ºÍ²¿ÊðÏîÄ¿”£¬È»ºóÑ¡Ôñ“Ä£°å”´°¸ñ ......