博客 (854)

学 ASP.NET 已经有些时候了,也经常利用 AJAX TOOLKIT 所提供的控件为自己的项目增添功能和特效,AJAX 总能给用户非常良好的体验。
今天开始,我会陆陆续续把 ASP.NET AJAX 1.0 开发和部署方面的一些要点摘录下来,以便自己今后方便使用,并给 .net 初学者提供一些学习参考,文中有不正确的地方,希望各位批评指正。我的编程语言使用 C#,使用 VB.NET 的朋友相信也能看得懂。网上有许多在线翻译 C# 和 VB 代码的工具,不用我说知道怎么做了吧~

这里使用 Microsoft Visual Studio 2005 作为 Web 开发的平台,从微软官方下载 VS2005 以及 VS2005 SP1 进行安装。当然也可以使用 Visual Web Developer 2005 Express Edition 进行开发。
首先从 ASP.NET AJAX 官方网站http://www.asp.net/ajax/下载最新的 Framework。
安装 AJAX.NET Extensions v1.0,很简单,按提示操作即可。
启动 VS,新建网站,选择 ASP.NET AJAX Enabled Web Site。

接下来做个简单的演示功能:
打开 Default.aspx 的设计器视图,从工具箱拖入一个 ScriptManager 控件到界面,这是任何一个 ASP.NET AJAX 网页所必需的,并且在放在所有其它控件的上面,它可以放在母板页,但也要保证在所有其它控件的最上面。
往设计器视图拖入三个 Label 控件和一个 Button 控件。在 Page_Load 事件中写入:

Label1.Text = DateTime.Now.ToString();
Label2.Text = DateTime.Now.ToString();
Label3.Text = DateTime.Now.ToString();

这时运行程序并点击按钮,三个 Label 都同时更新时间。
然后从工具箱拖入一个 UpdatePanel 到页面,把 Label2 和 Button1 移入 UpdatePanel 中,再运行一次,这时发现当点击按钮时只有 Label2 的内容是更新的,另外两个 Label 的值不变。这就是 UpdatePanel 的作用:局部更新。
这是一种方法,如果我们的界面设计必需把这个 Button1 放在 UpdatePanel 外面,而当点击按钮时只需更新 UpdatePanel 的内容时,可以这样做:
把 Button1 从 UpdatePanel 中移出到外面,转到“源”视图,在 asp:UpdatePanel 标签内部加入 Triggers 标签,再内建标签 asp:AsyncPostBackTrigger 代码如下:

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
<br />
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</form>

运行,点按钮试试,是不是跟刚才一样的效果呢?

3,825

 

安装ASP.NET AJAX

安装Toolkit:
下载解压AjaxControlToolkit.zip移至
C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\AjaxControlToolkit

安装模板C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\AjaxControlToolkit\AjaxControlExtender\AjaxControlExtender.vsi

若安装失败,手工建立以下文件夹:
\My Documents\Visual Studio 2005\Templates\ItemTemplates\Visual C#
\My Documents\Visual Studio 2005\Templates\ItemTemplates\Visual Basic
\My Documents\Visual Studio 2005\Templates\ProjectTemplates\Visual C#
\My Documents\Visual Studio 2005\Templates\ProjectTemplates\Visual Basic

把SampleWebSite\Bin下的AjaxControlToolkit.dll和AjaxControlToolkit.pdb
复制至Binaries下。
打开VS,添加选项卡AjaxControlToolkit,添加项浏览至Binaries\AjaxControlToolkit.dll

xoyozo 18 年前
5,127
    .Net 框架目前逐步在普及了,仍然有很多人在寻找如何让.NET程序脱离.NET框架的方法。
    现成的工具有 Xenocode 的postbuidle或者vas,还有 Salamander .NET Linker .另外还有 MaxToCode 作者以前做的 framework linker. 以及一些支持注册表模拟和文件模拟的打包工具molebox,thinstall等.
   最后还有某网友(应其要求隐去网名) 兜售的一个实现方法.

    Xenocode的是使用了一个虚拟机环境,模拟框架需要的注册表信息和文件信息.Xenocode号称的生成native代码功能实际上就是指的这个功能.我测试了几个程序打包,兼容性似乎不怎么好. 不知道是不是因为机器上已经安装了框架的原因。

    Jason做的 framework linker,以前我也使用过, 他的实际上是利用了Remotesoft的内核文件,然后自己实现了一个loader。好像是使用的早期的内核文件,兼容性也不太好。

    Salamander .Net Linker ,Remotesoft的一个产品,没有可以下载的,但是其兼容性似乎很不错。移动的飞信软件就利用了它的核心。

   某网友的方法似乎是利用remotesoft的核心和飞信的框架,因为他并没有免费公开方法,从他给出的样例可以看到有remotesoft的核心文件以及飞信的框架程序。

    这里要介绍的方法是直接利用飞信的框架来实现脱离 .Net framework运行。
    首先下载一个飞信的程序安装。在安装目录中会有 VMDotNet 目录。这个就是.Net框架虚拟环境需要的文件。直接把整个目录提取出来。

     如何利用这个虚拟环境运行 自己的 .Net 程序呢?
很简单,一个命令行搞定。在 VMDotNet 目录里面会找到一个 FetionVM.exe 。这个是虚拟环境的loader。
使用方法: FetionVM.exe pathtoyoureexe
就是直接把你的 .Net 程序 作为命令行参数传递给 FetionVM.exe 就可以在这个虚拟环境中执行你的。net程序了。
    最好再自己写一个启动程序,首先检查系统是否安装了。Net框架,如果有直接运行。没有调用虚拟环境运行。
    这个启动程序飞信也有,如果不想自己写就直接拿飞信安装目录中的 Feition.exe,但是这样的话 你自己的.Net程序的名字必须叫 FeitionFX.exe 。把它和Feition.exe 放在同一目录下,直接执行 Feition.exe 即可。
    另外,如果你对。Net程序使用了加密保护,需要注意一下,目前市面上的大部分。Net加密工具加密后的程序集不能在这个虚拟环境中运行的。 这个东西除了能实现脱离 。net框架运行外,还有另外一个副作用--让.net程序运行在指定版本的 。net 框架中(虽然机器上安装了。net框架,仍然可以让。net程序在这个虚拟框架下运行)。

   前面介绍了让.Net程序脱离.net framework框架 运行的方法 ,但是有些朋友应用中还是遇到了一些问题,主要时需要自己提取框架程序以及应用的dll问题。这里介绍一个偷懒提取方式。
  我们可以利用 Remotesoft linker的试用版来提取,试用版的获取

    http://www.remotesoft.com/linker/try.html

   试用版提取时可以用 mdeploy 方式或者 native 方式。如果时 mdeploy 方式,比较简单,直接提取出来了基本能用了。他提取的是你系统当前的 框架环境。也就是你安装了 .Net 3.0那么提取出来的核心文件也就是 3.0的。
   提取完后会有一个 exe文件和 rsm 文件,你只需要用fetion框架里面的 fetionvm.exe替换这里生成的exe文件即可。
实际上这个文件是一个预先写好了的模板程序,自己可以修改一下资源属性,就OK了。
   native 模式提取出来的虚拟框架目录结构和 fetion的那个一样的。把文件复制到fetion的框架里面覆盖。然后自己可以改改 fetionvm.srm文件,这个文件在前面已经还原出他的代码了。这样就省去了自己提取dll文件的麻烦。

6,273

在母板页"CS"加入:

public HyperLink MasterPageHyperLink3
{

get
{
return HyperLink3;
}

set
{
HyperLink3
= value;
}
}

在子页"源"加入:

<%@ MasterType VirtualPath="~/xoyozo/xoyozo.master" %>

即可在子页重写它:

Master.MasterPageHyperLink3.NavigateUrl = "ddddddd.html";

但最好放在Page_LoadComplete:

protected void Page_LoadComplete(object sender, EventArgs e)
{
}
xoyozo 18 年前
3,744
<add name="MySQLODBCDataConnectionString" connectionString="Driver=MySQL ODBC 3.51 Driver;server=localhost;Database=mydatabase;User=root;Password=0000000;"
providerName="System.Data.Odbc" />
xoyozo 18 年前
4,939
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="calender.aspx.cs" Inherits="___TEST___calender" %>

<!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 runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Calendar ID="calendar" runat="server" ShowGridLines="True" ShowDayHeader="True"
SelectionMode="Day" PrevMonthText="<<" NextMonthText=">>" DayNameFormat="Full"
DayHeaderStyle-HorizontalAlign="Center" Width="100%" TitleStyle-Font-Size="13px"
TodayDayStyle-BackColor="#ffffcc" DayStyle-Font-Size="13px" DayStyle-Font-Bold="True"
DayHeaderStyle-Font-Size="12px" OtherMonthDayStyle-ForeColor="#cccccc" OnDayRender="calendar_DayRender"
OnPreRender="calendar_PreRender">
<TodayDayStyle BackColor="#FFFFCC"></TodayDayStyle>
<OtherMonthDayStyle ForeColor="#CCCCCC"></OtherMonthDayStyle>
<DayStyle Font-Bold="True" Font-Size="13px"></DayStyle>
<DayHeaderStyle HorizontalAlign="Center" Font-Size="12px"></DayHeaderStyle>
<TitleStyle Font-Size="13px"></TitleStyle>
</asp:Calendar>
</div>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Threading;
using System.Data.OleDb;

public partial class ___TEST___calender : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void calendar_PreRender(object sender, EventArgs e)
{
//Thread t = Thread.CurrentThread;
//System.Globalization.CultureInfo c = (System.Globalization.CultureInfo)t.CurrentCulture.Clone();
//c.DateTimeFormat.DayNames = new string[] { "日", "一", "二", "三", "四", "五", "六" };
//c.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Monday;
//t.CurrentCulture = c;
}
int preMonth, curMonth, nextMonth;
int[] preMonthArray, curMonthArray, nextMonthArray;
protected Calendar calendar1; //日历控件
protected void calendar_DayRender(object sender, DayRenderEventArgs e)
{
CalendarDay day = e.Day; //事件参数e,包含了年月日等信息
TableCell cell = e.Cell;

preMonth = day.Date.Month;
curMonth = (preMonth + 1 > 12) ? 1 : (preMonth + 1);
nextMonth = (curMonth + 1 > 12) ? 1 : (curMonth + 1);

curMonthArray = getBlogArray(day.Date.Year, curMonth);
preMonthArray = getBlogArray(day.Date.Year, preMonth);
nextMonthArray = getBlogArray(day.Date.Year, nextMonth);

int j = 0;
if (day.Date.Month.Equals(preMonth))
{
while (preMonthArray[j] != 0)
{
if (day.Date.Day == preMonthArray[j])
{
cell.Controls.Clear();
cell.Controls.Add(new LiteralControl("<a href='showBlog.aspx?tid=" + day.Date.Year.ToString() + day.Date.Month.ToString() + day.Date.Day.ToString() + "' style='color:#0000ff' target='main'>" + day.Date.Day.ToString() + "</a>"));
cell.Controls.Add(new LiteralControl("<br> 哈哈哈"));
}
j++;
}
}
else if (day.Date.Month.Equals(nextMonth))
{
while (nextMonthArray[j] != 0)
{
if (day.Date.Day == nextMonthArray[j])
{
cell.Controls.Clear();
cell.Controls.Add(new LiteralControl("<a href='showBlog.aspx?tid=" + day.Date.Year.ToString() + day.Date.Month.ToString() + day.Date.Day.ToString() + "' style='color:#0000ff' target='main'>" + day.Date.Day.ToString() + "</a>"));
}
j++;
}
}
else if (day.Date.Month.Equals(curMonth))
{
while (curMonthArray[j] != 0)
{
if (day.Date.Day == curMonthArray[j])
{
cell.Controls.Clear();
cell.Controls.Add(new LiteralControl("<a href='showBlog.aspx?tid=" + day.Date.Year.ToString() + day.Date.Month.ToString() + day.Date.Day.ToString() + "' style='color:#0000ff' target='main'>" + day.Date.Day.ToString() + "</a>"));
}
j++;
}
}
}
protected int[] getBlogArray(int year, int month)
{
int[] array = new int[31];
int i;
for (i = 0; i < 31; i++)
array[i] = 3;
i = 0;
OleDbConnection conn = new OleDbConnection(ConfigurationManager.ConnectionStrings["LocalXoyozoConnectionString"].ToString());
conn.Open();
OleDbCommand cmd = new OleDbCommand("SELECT [posttime] FROM [blogdata] WHERE month([posttime])=@month AND year([posttime])=@year", conn);
cmd.Parameters.Add("@month", OleDbType.Integer, 2, "month");
cmd.Parameters["@month"].Value = month;
cmd.Parameters.Add("@year", OleDbType.Integer, 2, "year");
cmd.Parameters["@year"].Value = year;

OleDbDataReader r = cmd.ExecuteReader();
while (r.Read())
{
array[i++] = r.GetDateTime(0).Day;
}
r.Close();
conn.Close();
return array;
}
}
7,665
string chkCode = string.Empty;
//颜色列表,用于验证码、噪线、噪点
//Color[] color ={Color.White, Color.Yellow, Color.LightBlue, Color.LightGreen,
//                Color.Orange, Color.LightCyan, Color.LightPink, 
//                Color.LightSalmon };
Color[] color = {Color.Black, Color.Blue, Color.Red, Color.DarkViolet, 
                 Color.Chocolate, Color.DarkGreen, Color.DeepSkyBlue, 
                 Color.DarkCyan };
//字体列表,用于验证码 
string[] font = {"Times New Roman", "MS Mincho", "Book Antiqua", "Gungsuh",
                 "PMingLiU", "Impact" };
//验证码的字符集,去掉了一些容易混淆的字符 
char[] character ={'2', '3', '4', '5', '6', '8', '9', 'A', 'B', 'C', 'D', 'E',
                   'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T',
                   'W', 'X', 'Y' };
Random rnd = new Random();
//生成验证码字符串 
for (int i = 0; i < 4; i++)
{
    chkCode += character[rnd.Next(character.Length)];
}
//把验证码存入session
Session["chkCode"] = chkCode;
Bitmap bmp = new Bitmap(65, 20);
Graphics g = Graphics.FromImage(bmp);
g.Clear(Color.Transparent);//背景色
//画噪线 
for (int i = 0; i < 0; i++)
{
    int x1 = rnd.Next(65);
    int y1 = rnd.Next(20);
    int x2 = rnd.Next(65);
    int y2 = rnd.Next(20);
    Color clr = color[rnd.Next(color.Length)];
    g.DrawLine(new Pen(clr), x1, y1, x2, y2);
}
//画验证码字符串
for (int i = 0; i < chkCode.Length; i++)
{
    string fnt = font[rnd.Next(font.Length)];
    Font ft = new Font(fnt, 15);
    Color clr = color[rnd.Next(color.Length)];
    g.DrawString(chkCode[i].ToString(), ft, new SolidBrush(clr),
        (float)i * 15 + 2, (float)0);
}
//画噪点 
for (int i = 0; i < 50; i++)
{
    int x = rnd.Next(bmp.Width);
    int y = rnd.Next(bmp.Height);
    Color clr = color[rnd.Next(color.Length)];
    bmp.SetPixel(x, y, clr);
}
//清除该页输出缓存,设置该页无缓存 
Response.Buffer = true;
Response.ExpiresAbsolute = System.DateTime.Now.AddMilliseconds(0);
Response.Expires = 0;
Response.CacheControl = "no-cache";
Response.AppendHeader("Pragma", "No-Cache");
//将验证码图片写入内存流,并将其以 "image/Png" 格式输出 
MemoryStream ms = new MemoryStream();
try
{
    bmp.Save(ms, ImageFormat.Png);
    Response.ClearContent();
    Response.ContentType = "image/Png";
    Response.BinaryWrite(ms.ToArray());
}
finally
{
    //显式释放资源 
    bmp.Dispose();
    g.Dispose();
}
xoyozo 18 年前
6,014

CatalogEdit.aspx

<asp:ListBox ID="ListBox1" runat="server" DataSourceID="SqlDataSource1" DataTextField="catalog"
DataValueField="ID" Rows="10"></asp:ListBox>
<asp:LinkButton ID="LinkButton_up" runat="server" OnClick="LinkButton_up_Click">上移</asp:LinkButton>
<asp:LinkButton ID="LinkButton_down" runat="server" OnClick="LinkButton_down_Click">下移</asp:LinkButton>
<asp:LinkButton ID="LinkButton_del" runat="server" OnClick="LinkButton_del_Click">删除</asp:LinkButton>
<asp:Label ID="Label_alert" runat="server" ForeColor="Red" Text="Label"></asp:Label><br />
<asp:TextBox ID="TextBox_newCatalog" runat="server"></asp:TextBox>
<asp:LinkButton ID="LinkButton_add" runat="server" OnClick="LinkButton_add_Click">新增</asp:LinkButton>
<asp:LinkButton ID="LinkButton_edit" runat="server" OnClick="LinkButton_edit_Click">修改</asp:LinkButton>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringLink %>"
DeleteCommand="DELETE FROM [xLinkCategory] WHERE [ID] = ?" InsertCommand="INSERT INTO [xLinkCategory] ([username],[catalog],[order]) VALUES (?,?,0)"
ProviderName="<%$ ConnectionStrings:ConnectionStringLink.ProviderName %>"
SelectCommand="SELECT [ID], [catalog] FROM [xLinkCategory] WHERE ([username] = ?) ORDER BY [order],[ID] desc"
UpdateCommand="UPDATE [xLinkCategory] SET [catalog] = ? WHERE [ID] = ?">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="catalog" Type="String" />
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
<SelectParameters>
<asp:SessionParameter Name="username" SessionField="username" Type="String" />
</SelectParameters>
<InsertParameters>
<asp:SessionParameter Name="username" SessionField="username" Type="String" />
<asp:Parameter Name="catalog" Type="String" />
</InsertParameters>
</asp:SqlDataSource>

CatalogEdit.aspx.cs

/**//// <summary>
/// 上移
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void LinkButton_up_Click(object sender, EventArgs e)
{
if (ListBox1.SelectedItem != null && ListBox1.SelectedIndex > 0)
{
string tempValue = ListBox1.SelectedValue;
string tempText = ListBox1.SelectedItem.Text;
int index = ListBox1.SelectedIndex;

ListBox1.SelectedItem.Value = ListBox1.Items[index - 1].Value;
ListBox1.SelectedItem.Text = ListBox1.Items[index - 1].Text;
ListBox1.Items[index - 1].Value = tempValue;
ListBox1.Items[index - 1].Text = tempText;

ListBox1.SelectedIndex--;

operateDB_move();
}
}
/**//// <summary>
/// 下移
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void LinkButton_down_Click(object sender, EventArgs e)
{
if (ListBox1.SelectedItem != null && ListBox1.SelectedIndex < ListBox1.Items.Count - 1)
{
string tempValue = ListBox1.SelectedValue;
string tempText = ListBox1.SelectedItem.Text;
int index = ListBox1.SelectedIndex;

ListBox1.SelectedItem.Value = ListBox1.Items[index + 1].Value;
ListBox1.SelectedItem.Text = ListBox1.Items[index + 1].Text;
ListBox1.Items[index + 1].Value = tempValue;
ListBox1.Items[index + 1].Text = tempText;

ListBox1.SelectedIndex++;

operateDB_move();
}
}
/**//// <summary>
/// 添加
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void LinkButton_add_Click(object sender, EventArgs e)
{
if (TextBox_newCatalog.Text != "")
{
//检查同名
bool goon = true;
foreach (ListItem li in ListBox1.Items)
{
if (li.Text == TextBox_newCatalog.Text)
{
goon = false;
}
}

if (goon)
{
//操作
SqlDataSource1.InsertParameters["catalog"].DefaultValue = TextBox_newCatalog.Text;
SqlDataSource1.Insert();

//设置selected
if (ListBox1.Items.Count > 0)
{
ListBox1.SelectedIndex = 0;
}
}
else
{
Label_alert.Text = "已存在";
}
}
}
/**//// <summary>
/// 修改
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void LinkButton_edit_Click(object sender, EventArgs e)
{
if (TextBox_newCatalog.Text != "" && ListBox1.SelectedItem != null)
{
int index = ListBox1.SelectedIndex;

//检查同名
bool goon = true;
foreach (ListItem li in ListBox1.Items)
{
if (li.Text == TextBox_newCatalog.Text)
{
goon = false;
}
}

if (goon)
{
//操作
SqlDataSource1.UpdateParameters["catalog"].DefaultValue = TextBox_newCatalog.Text;
SqlDataSource1.UpdateParameters["ID"].DefaultValue = ListBox1.SelectedItem.Value;
SqlDataSource1.Update();

//设置selected
ListBox1.SelectedIndex = index;
}
else
{
Label_alert.Text = "已存在";
}
}
}
/**//// <summary>
/// 删除
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void LinkButton_del_Click(object sender, EventArgs e)
{
if (ListBox1.SelectedItem != null)
{
int index = ListBox1.SelectedIndex;
int count = ListBox1.Items.Count;

//检查该 Catalog 下是否有 Link
bool goon = true;
goon = !checkSubLink(ListBox1.SelectedValue); //下有 Link 则返回真,注意前面有个"!",有则不继续

if (goon)
{
//操作
SqlDataSource1.DeleteParameters["ID"].DefaultValue = ListBox1.SelectedItem.Value;
SqlDataSource1.Delete();

//设置selected
if (index < count - 1) //删的不是最末项
{
ListBox1.SelectedIndex = index;
}
if (index == count - 1 && index != 0) //删的是最末项,并且不是最首项
{
ListBox1.SelectedIndex = index - 1;
}
if (index == count - 1 && index == 0) //删的是最末项,并且是最首项
{
//不设索引
}
}
else
{
Label_alert.Text = "该节点下面存在Link(s),请删除后再删除该节点!";
}
}
}
xoyozo 18 年前
4,276
IEnumerator SessionEnum = Session.Keys.GetEnumerator();
while (SessionEnum.MoveNext())
{
    Label1.Text += Session[SessionEnum.Current.ToString()].ToString() + "
";
}
xoyozo 18 年前
6,583
public static bool loadRss(string RssUrl, int RssCount)
{
bool ok = true;
XmlDocument doc = new XmlDocument();
if (RssUrl != "")
{
try
{
doc.Load(RssUrl);
XmlNodeList nodelist = doc.GetElementsByTagName("item");
XmlNodeList objItems1;

int i = 0;
int count = 0;

if (doc.HasChildNodes)
{
foreach (XmlNode node in nodelist)
{
string title = "";
string link = "";
string description = "";
string pubDate = "";
i += 1;
if (node.HasChildNodes)
{
objItems1 = node.ChildNodes;
foreach (XmlNode node1 in objItems1)
{
switch (node1.Name)
{
case "title":
title = node1.InnerText;
break;
case "link":
link = node1.InnerText;
break;
case "description":
description = node1.InnerText;
break;
case "pubDate":
pubDate = node1.InnerText;
break;
default: break;
}
}
}
if (i > RssCount)
{
break;
}
}
}
}
catch (Exception ex)
{
ok = false;
}
}

return ok;
}
xoyozo 18 年前
5,218