在asp.net 使用ajax 弹出的JS对话框
2010-03-29 23:49
393 查看
using System;
using System.Data;
using System.Configuration;
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;
namespace ASPNETAJAXWeb.AjaxUser
{
public class AjaxUserSystem
{
public AjaxUserSystem()
{
}
/// <summary>
/// 在ASP.NET环境中弹出一个对话框
/// </summary>
/// <param name="response"></param>
/// <param name="message"></param>
public static void ShowDialog(HttpResponse response,string message)
{
response.Write("<script>alert(\"" + message + "\");</script>");
}
/// <summary>
/// 在ajax环境中弹出一个对话框
/// </summary>
/// <param name="button"></param>
/// <param name="message"></param>
public static void ShowAjaxDialog(Button button,string message)
{
ScriptManager.RegisterClientScriptBlock(button,typeof(Button),button.ClientID,message,true);
}
///
public static void ShowAjaxDialog(Page page,string message)
{
ScriptManager.RegisterClientScriptBlock(page,typeof(Page),DateTime.Now.ToString().Replace(":"," "),"alert('"+message"')",true);
}
/// <summary>
/// 根据Value属性把列表控件的选择项设置为指定项
/// </summary>
/// <param name="list"></param>
/// <param name="value"></param>
public static void ListSelectedItemByValue(ListControl list,string value)
{
if(list == null) return;
///选择项为空
if(list.Items.Count <= 0)
{
list.SelectedIndex = -1;
return;
}
///逐项进行比较,设置选择项
for(int i = 0; i < list.Items.Count; i++)
{
if(list.Items[i].Value == value)
{
list.SelectedIndex = i;
return;
}
}
///没有符合条件的选择项
list.SelectedIndex = -1;
}
/// <summary>
/// 根据Text属性把列表控件的选择项设置为指定项
/// </summary>
/// <param name="list"></param>
/// <param name="text"></param>
public static void ListSelectedItemByText(ListControl list,string text)
{
if(list == null) return;
///选择项为空
if(list.Items.Count <= 0)
{
list.SelectedIndex = -1;
return;
}
///逐项进行比较,设置选择项
for(int i = 0; i < list.Items.Count; i++)
{
if(list.Items[i].Text == text)
{
list.SelectedIndex = i;
return;
}
}
///没有符合条件的选择项
list.SelectedIndex = -1;
}
/// <summary>
/// 根据时间创建字符串
/// </summary>
/// <returns></returns>
public static string CreateDateTimeString()
{
DateTime now = DateTime.Now;
string dtString = now.Year.ToString()
+ now.Month.ToString().PadLeft(2,'0')
+ now.Day.ToString().PadLeft(2,'0')
+ now.Hour.ToString().PadLeft(2,'0')
+ now.Minute.ToString().PadLeft(2,'0')
+ now.Second.ToString().PadLeft(2,'0')
+ now.Millisecond.ToString().PadLeft(3,'0');
return (dtString);
}
}
}
“七”乐无穷,尽在新浪新版博客,快来体验啊~~~请点击进入~
using System.Data;
using System.Configuration;
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;
namespace ASPNETAJAXWeb.AjaxUser
{
public class AjaxUserSystem
{
public AjaxUserSystem()
{
}
/// <summary>
/// 在ASP.NET环境中弹出一个对话框
/// </summary>
/// <param name="response"></param>
/// <param name="message"></param>
public static void ShowDialog(HttpResponse response,string message)
{
response.Write("<script>alert(\"" + message + "\");</script>");
}
/// <summary>
/// 在ajax环境中弹出一个对话框
/// </summary>
/// <param name="button"></param>
/// <param name="message"></param>
public static void ShowAjaxDialog(Button button,string message)
{
ScriptManager.RegisterClientScriptBlock(button,typeof(Button),button.ClientID,message,true);
}
///
public static void ShowAjaxDialog(Page page,string message)
{
ScriptManager.RegisterClientScriptBlock(page,typeof(Page),DateTime.Now.ToString().Replace(":"," "),"alert('"+message"')",true);
}
/// <summary>
/// 根据Value属性把列表控件的选择项设置为指定项
/// </summary>
/// <param name="list"></param>
/// <param name="value"></param>
public static void ListSelectedItemByValue(ListControl list,string value)
{
if(list == null) return;
///选择项为空
if(list.Items.Count <= 0)
{
list.SelectedIndex = -1;
return;
}
///逐项进行比较,设置选择项
for(int i = 0; i < list.Items.Count; i++)
{
if(list.Items[i].Value == value)
{
list.SelectedIndex = i;
return;
}
}
///没有符合条件的选择项
list.SelectedIndex = -1;
}
/// <summary>
/// 根据Text属性把列表控件的选择项设置为指定项
/// </summary>
/// <param name="list"></param>
/// <param name="text"></param>
public static void ListSelectedItemByText(ListControl list,string text)
{
if(list == null) return;
///选择项为空
if(list.Items.Count <= 0)
{
list.SelectedIndex = -1;
return;
}
///逐项进行比较,设置选择项
for(int i = 0; i < list.Items.Count; i++)
{
if(list.Items[i].Text == text)
{
list.SelectedIndex = i;
return;
}
}
///没有符合条件的选择项
list.SelectedIndex = -1;
}
/// <summary>
/// 根据时间创建字符串
/// </summary>
/// <returns></returns>
public static string CreateDateTimeString()
{
DateTime now = DateTime.Now;
string dtString = now.Year.ToString()
+ now.Month.ToString().PadLeft(2,'0')
+ now.Day.ToString().PadLeft(2,'0')
+ now.Hour.ToString().PadLeft(2,'0')
+ now.Minute.ToString().PadLeft(2,'0')
+ now.Second.ToString().PadLeft(2,'0')
+ now.Millisecond.ToString().PadLeft(3,'0');
return (dtString);
}
}
}
“七”乐无穷,尽在新浪新版博客,快来体验啊~~~请点击进入~
相关文章推荐
- ASP.NET2.0中ClientScriptManager的用法(使用ASP.NET 2.0 AJAX 弹出对话框)
- 使用ASP.NET 2.0 AJAX 弹出对话框
- ASP.NET2.0中ClientScriptManager的用法(使用ASP.NET 2.0 AJAX 弹出对话框)
- 在使用ASP.NET AJAX时用alert弹出对话框
- ASP.NET Ajax控件弹出JS对话框
- asp.net使用ajax后如何在客户端弹出提示对话框
- asp.net使用ajax后如何在客户端弹出提示对话框
- asp.net ajax 无法弹出JS对话框
- ASP.NET中使用AJAX时如何弹出对话框
- 如何在ASP.NET中使用弹出对话框?
- JS弹出对话框返回值代码(asp.net后台)
- ASP.NET 使用alert弹出对话框后,CSS样式失效,字体变大的解决方法
- ASP.NET 使用alert弹出对话框后,CSS样式失效,字体变大的解决方法
- asp.net 使用UpdatePanel 返回服务器处理后弹出对话框
- ASP.NET应用Ajax 无法弹出对话框
- ASP.NET AJAX时用alert弹出对话框
- ASP.NET 使用alert弹出对话框后,CSS样式失效,字体变大的解决方法
- asp.net在用ajax的时候如何弹出对话框
- 解决AJAX中使用UpdatePanel后无法弹出js对话框问题(引)
- 利用js在asp.net中验证是否重复弹出对话框并导向网址