2008年10月9日 星期四

開啟子頁時,要有bar~~~~~

window.open(url,winTitle,option)

option的內容加「scrollbars=yes」

2008年10月2日 星期四

在cs中,導到別頁時,以另開新頁的方式開啟

直接導到別頁的方式:Response.Redirect("網址");

以另開新頁的導頁方式:
public static void OpenWindowToNewPage(Page page, string destUrl)
{
//開一新視窗
string scriptString = string.Format("< language="'JavaScript'">window.open(\"{0}\",'NewPage');<", destUrl);
scriptString += "/";
scriptString += "script >";
Type cstype = page.GetType();
if (!page.ClientScript.IsStartupScriptRegistered("Startup"))
{
page.ClientScript.RegisterStartupScript(cstype, "Startup", scriptString);
}
}
使用方式: OpenWindowToNewPage(this.Page, "網址");


感謝Darren提供

在cs中直接呼叫javascript,不用在click事件

aspx
function Open()
{
var question="";
var question = confirm("Message?")
if (question)
{
window.open("http://","","width=600,height=400,toolbar=0,status=0,menubar=0,resize=0");
//開啟視窗
//window.open("http://");整個視窗
}
}

cs
string script = "< language="'javascript'">Open()< /script>";
ClientScript.RegisterStartupScript(this.GetType(), "n1", script);

立即取得CheckBoxList目前勾選的選項

一般都是用foreach來取得勾選了哪些選項,但如有筆數限定時,要馬上告知user已超出可勾選的筆數,此方式就不適用了!

可改用:

SelectedIndexChanged事件
string args = Request["__EVENTTARGET"];
char[] delimiterChars = { '$' };
string[] words = args.Split(delimiterChars);
int ix = Convert.ToInt16(words[words.Length - 1]);

foreach (ListItem item in CheckBoxList.Items)
{
if (item.Selected)
{
if (!判斷目前所勾選的筆數)
CheckBoxList.Items[ix].Selected = false;
}
}


參考網址:http://phone.idv.tw/cs2/forums/thread/510.aspx

感謝協助我的人^^