DropDownList 選項改變確認腳本
需要這個, 到網找了某先生的腳本改了改 ![](/Emoticons/emwink.gif)
static public string DropDownListSelectChangeConfirmScript(string dropDownListId,string message)
{
string script = " <script> \n"
+" var fooIndex; \n"
+" function saveIndexes() \n"
+" { \n"
+" fooIndex = document.all['"+dropDownListId+"'].selectedIndex; \n"
+" } \n"
+" function resetIndexes() \n"
+" { \n"
+" document.all['"+dropDownListId+"'].selectedIndex = fooIndex; \n"
+" } \n"
+" function areYouSure() \n"
+" { \n"
+" if( !confirm('"+message+"')) \n"
+" { \n"
+" resetIndexes(); \n"
+" return false; \n"
+" } \n"
+" else \n"
+" { \n"
+" document.all['"+dropDownListId+"'].detachEvent('onchange', areYouSure); \n"
+" return true; \n"
+" } \n"
+" } \n"
+" saveIndexes(); \n"
+" document.all['"+dropDownListId+"'].attachEvent('onchange', areYouSure); "
+"</script>\n";
return script;
}
private void RegisterClientScript(string dropDownListClientId)
{
string script = DropDownListSelectChangeConfirmScript(
dropDownListClientId,
"Are you sure?"
);
if(!IsStartupScriptRegistered("startup"))
{
RegisterStartupScript("startup",script);
}
![](/Images/OutliningIndicators/InBlock.gif)
}
![](/Emoticons/emwink.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](/Images/OutliningIndicators/None.gif)