国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

ASP.NET 常見問題 和 網(wǎng)頁上加上百度搜索

2024-07-10 13:06:48
字體:
供稿:網(wǎng)友

如何在類庫中的類文件里使用response,request,server,session幾種對象。我這里有如下方式,僅供參考:
      首先我們要在類文件里引用using system.web;using system.web.sesstionstate;命名空間,然后是對這種對象的聲明:
       httpsessionstate session;
       httpserverutility server;
       httprequest request;
       httpresponse response;

最后我們可以在構(gòu)造函數(shù)里做如下處理:
      try
      {
            session = ((system.web.ui.page)parent).session;
            server = ((system.web.ui.page)parent).server;
            request = ((system.web.ui.page)parent).request;
            response = ((system.web.ui.page)parent).response;
      }
      catch
      {
            server = ((system.web.ui.usercontrol)parent).server;
            session = ((system.web.ui.usercontrol)parent).session;
            request = ((system.web.ui.usercontrol)parent).request;
            response = ((system.web.ui.usercontrol)parent).response;
      }
以上做完,你就可以在類庫里直接使用這幾種對象了。
返回歷史頁面
在提交的時候過程很長,為了防止用戶再次點擊而且為了界面友好可以用一個層遮住所有按鈕再顯示個提示信息,等服務(wù)器端處理完成再導(dǎo)航到本頁(location.href='地址')就可以:


<div id="doing" runat="server" >
                <table width="100%" height="100%">
                    <tr align="center" valign="middle">
                        <td>
                            <table width="169" class="font3" height="62" bgcolor="#6699ff" >
                                <tr align="center" valign="middle">
                                    <td>頁面提交中,請等待<br>
                                        please wait
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </div>

pageload里面這么寫:this.button1.attributes.add("onclick","document.getelementbyid('doing').style.visibility='visible';");
,等操作結(jié)束重定向了后頁面重新加載一次,這個層也就消失了。。。


page.smartnavigation 屬性
獲取或設(shè)置指示是否啟用智能導(dǎo)航的值


如果啟用智能導(dǎo)航,則為 true;否則為 false。

備注
在大多數(shù)情況下不要在代碼中設(shè)置該屬性。在 .aspx 文件的 @ page 指令中將 smartnavigation 屬性設(shè)置為 true。請求該頁時,動態(tài)生成的類將設(shè)置該屬性。

internet explorer 5.5 或更高版本瀏覽器請求頁時(或稍后),智能導(dǎo)航將通過執(zhí)行下列功能提高用戶對該頁的操作能力:

消除導(dǎo)航導(dǎo)致的閃爍。
從一頁移動到另一頁時保持滾動位置。
保持導(dǎo)航之間的元素焦點。
在瀏覽器的歷史記錄中只保留最后一頁的狀態(tài)。
智能導(dǎo)航最適用于需要頻繁回發(fā)但是其可是內(nèi)容在返回時不會發(fā)生顯著更改的 asp.net 頁。在決定是否將該屬性設(shè)置為 true 時,請仔細(xì)考慮這一點。


[c#]
void page_load(object sender, eventargs e)
{
   this.smartnavigation = true;
}
void button_click(object sender, eventargs e)
{
   label1.text="<b>the value of 'smartnavigation' property is </b>" + "'" + this.smartnavigation + "'";
}

它最外邊還是有一個frameset。你可以注意到與ajax的區(qū)別就是窗口底下多了個一閃而過的藍(lán)色進(jìn)度條(我真希望ie能有辦法去掉這個)。其實很簡單,幾秒鐘搞定!就是把你的頁面的屬性 smartnavigation 設(shè)置為 true
1遇到的問題:
使用了驗證控件,編譯時提示“無法找到腳本庫……”
解決方法:
由于更換了主目錄路徑,應(yīng)將在wwwroot下的aspnet_client文件夾拷到新的目錄下即可


 

2遇到的問題:
關(guān)于style中的alpha濾鏡
解決方法:
濾鏡說明:
alpha:設(shè)置透明層次.
濾鏡:alpha
語法:
style="filter:alpha(opacity=opacity,finishopacity=finishopacity,style=style,startx=startx,starty=starty,finishx=finishx,finishy=finishy)"
說明:
opacity:起始值,取值為0-100,0為透明,100為原圖.

finishopacity:目標(biāo)值.

style:1或2或3

startx:任意值

starty:任意值

例子1:filter:alpha(opacity="0",finishopacity="40",style="2")

例子2:<div id="mymenu" >(即半透明)

附常見濾鏡:

style的css設(shè)置 2005-5-5 11:54:18

語法:style="filter:filtername(fparameter1,fparameter2...)}(filtername為濾鏡的名稱,fparameter1、fparameter2等是濾鏡的參數(shù))

 

濾鏡說明:

alpha:設(shè)置透明層次.

blur:創(chuàng)建高速度移動效果,即模糊效果.

chroma:制作專用顏色透明.

dropshadow:創(chuàng)建對象的固定影子.

fliph:創(chuàng)建水平鏡像圖片.

flipv:創(chuàng)建垂直鏡像圖片.

glow:加光輝在附近對象的邊外.

gray:把圖片灰度化.

invert:反色.

light:創(chuàng)建光源在對象上.

mask:創(chuàng)建透明掩膜在對象上.

shadow:創(chuàng)建偏移固定影子.

wave:波紋效果.

xray:使對象變的像被x光照射一樣.

 

1.濾鏡:alpha

語法:

style="filter:alpha(opacity=opacity,finishopacity=finishopacity,style=style,

startx=startx,starty=starty,finishx=finishx,finishy=finishy)"

說明:

opacity:起始值,取值為0-100,0為透明,100為原圖.

finishopacity:目標(biāo)值.

style:1或2或3

startx:任 ?

starty:任意值

例子:filter:alpha(opacity="0",finishopacity="40",style="2")

 

2.濾鏡:blur

語法:

style="filter:blur(add=add,direction=direction,strength=strength)"

說明:

add:一般為1,或0.

direction:角度,0-315度,步長為45度.

strength:效果增長的數(shù)值,一般5即可.

例子:filter:blur(add="1",direction="45",strength="5")

 

3.濾鏡:chroma

語法:

style="filter:chroma(color=color)"

說明:

color:#rrggbb格式,任意.

例子:filter:chroma(color="#ffffff")

 

4.濾鏡:dropshadow

語法:

style="filter:dropshadow(color=color,offx=offx,offy=offy,positive=positive)"

說明:

color:#rrggbb格式,任意.

offx:x軸偏離值.

offy:y軸偏離值.

positive:1或0.

例子:filter:dropshadow(color="#6699cc",offx="5",offy="5",positive="1")

 

5.濾鏡:fliph

語法:

style="filter:fliph"

例子:filter:fliph

 

6.濾鏡:flipv

語法:

style="filter:flipv"

例子:filter:flipv

 

7.濾鏡:glow

語法:

style="filter:glow(color=color,strength=strength)"

說明:

color:發(fā)光顏色.

strength:強(qiáng)度(0-100)

例子:filter:glow(color="#6699cc",strength="5")

 

8濾鏡:gray

語法:

style="filter:gray"

例子:filter:gray

 

9.濾鏡:invert

語法:

style="filter:invert"

例子:filter:invert

 

10.濾鏡:mask

語法:

style="filter:mask(color=color)"

例子:filter:mask(color="#ffffe0")

 

11.濾鏡:shadow

語法:

filter:shadow(color=color,direction=direction)

說明:

color:#rrggbb格式.

direction:角度,0-315度,步長為45度.

例子:filter:shadow(color="#6699cc",direction="135")

 

12.濾鏡:wave

語法:

filter:wave(add=add,freq=freq,lightstrength=strength,phase=phase,strength=strength)

說明:

add:一般為1,或0.

freq:變形值.

lightstrength:變形百分比.

phase:角度變形百分比.

strength:變形強(qiáng)度.

例子:filter:wave(add="0",phase="4",freq="5",lightstrength="5",strength="2")

 

13.濾鏡:xray

語法:

style="filter:xray"

例子:filter:xray 


 

3遇到的問題:

關(guān)于arraylist、ienumerator?

解決方法:

arraylist a=new arraylist();

              string s1="aaaaa";

              string s2="bbbbb";

              string s3="ccccc";

              int i1=1;

              int i2=2;

              int i3=3;

 

              a.add(s1);

              a.add(s2);

              a.add(i1);

              a.add(i2);   

              a.add(i3);

              a.add(s3);

 

              ienumerator ie=a.getenumerator();

              while(ie.movenext())

              {

                   string s=ie.current.tostring();

                   response.write(s+environment.newline);

              }

(與直接對arraylist對象用下標(biāo)訪問或通過foreach訪問有什么區(qū)別?)


 

4遇到的問題:

關(guān)于arraylist

解決方法:

一. arraylist 構(gòu)造函數(shù)

 

1. public arraylist(); 

    初始容量是新arraylist的起始容量。arraylist 的默認(rèn)初始容量為16。 如果添加到列表中的元素個數(shù)達(dá)到當(dāng)前容量,則容量將自動增加一倍。

 

2. public arraylist(icollection);

    初始容量是新arraylist 的起始容量。如果添加到列表中的元素個數(shù)達(dá)到當(dāng)前容量,則容量將自動增加一倍。按照由icollection 的ienumerator 讀取元素的順序?qū)⑦@些元素復(fù)制到arraylist 中。

 

3. public arraylist(int);

    初始容量是新arraylist 的起始容量。arraylist 的默認(rèn)初始容量為16。如果指定的初始容量為0,則使用默認(rèn)的初始容量。如果添加到列表中的元素個數(shù)達(dá)到當(dāng)前容量,則容量將自動增加一倍。因此,如果可以估計集合的大小,那么當(dāng)指定初始容量后,將無需在向arraylist 中添加元素時執(zhí)行大量的大小調(diào)整操作。

 

二. arraylist 成員

 

1. 常用屬性

capacity:獲取或設(shè)置arraylist 可包含的元素數(shù)。

count:獲取 arraylist中實際包含的元素數(shù)。

item:獲取或設(shè)置指定索引處的元素。在 c# 中,該屬性為arraylist類的索引器。

 

2.常用方法

add:將對象添加到arraylist的結(jié)尾處。

clear:從arraylist 中移除所有元素。

indexof:返回arraylist 或它的一部分中某個值的第一個匹配項的從零開始的索引。

lastindexof:返回arraylist或它的一部分中某個值的最后一個匹配項的從零開始的索引。

insert:將元素插入arraylist的指定索引處。

remove:從arraylist中移除特定對象的第一個匹配項。

removeat:移除arraylist的指定索引處的元素。

trimtosize:將容量設(shè)置為arraylist中元素的實際數(shù)量。


 

5遇到的問題:

關(guān)于動態(tài)修改html中的某些內(nèi)容

解決方法:

例如,改變頁面的title

1)

                   <script language =javascript >

                            window.document.title =tl;

                   </script>

.cs中:

              string s="123456";

              response.write("<script language=javascript>var tl='"+ s +"'</script>");

 

2)

                   <title><%=s%></title>

.cs中:

         public string s="123456";

使用protected修飾也行,但internal修飾則出錯,???

 

3)

                   <title><%=method()%></title>

.cs中:

         public string method()

         {

              return "123456";

         }

同二,使用internal修飾也不行???


 

6遇到的問題:

關(guān)于params關(guān)鍵字

解決方法:

         private void page_load(object sender, system.eventargs e)

         {

              // 在此處放置用戶代碼以初始化頁面

              string[] sarray=new string[3];

              sarray[0]="aaa";

              sarray[1]="bbb";

              sarray[2]="ccc";

 

              method1(sarray);

//            method1("aaa","bbb","ccc");      //error

 

              method2(sarray);

              method2("aaa","bbb","ccc");

 

         }

 

         private void method1(string[] s)

         {

              string temp="";

              foreach(string e in s)

              {

                   temp+=e;

              }

              this.textbox1.text =temp;

         }

 

         private void method2(params string[] s)

         {

              string temp="";

              foreach(string e in s)

              {

                   temp+=e;

              }

              this.textbox2.text =temp;

         }


 

7遇到的問題:

關(guān)于__dopostback()方法?

解決方法:

頁面一:

提供一個錨點:

<a >open webform2</a>

一個文本框,用于顯示一些信息:

<asp:textbox id="textbox1" runat="server"></asp:textbox>

一個隱藏的服務(wù)器button:

<asp:button id="button1" runat="server" text="button" visible="false"></asp:button>

button的后臺事件為:

private void button1_click(object sender, system.eventargs e)

{

     this.textbox1.text ="has click...";

}

頁面二:

添加一個服務(wù)器按鈕,添加事件:

private void button1_click(object sender, system.eventargs e)

{

     string s="<script language=javascript>";

     s+="window.opener.__dopostback('button1','');";

     s+="</script>";

 

     this.page.registerclientscriptblock("a",s);

}

此時,在頁面二中無法成功地觸發(fā)頁面一中的__dopostback()事件,是由于在沒有某些特定控件的時候,html文件中并不會產(chǎn)生__dopostback()函數(shù)的javascript代碼,所以在頁面二中點擊按鈕時會提示“對象不支持此方法”:

<script language="javascript">

<!--

     function __dopostback(eventtarget, eventargument)

{

         var theform;

         if (window.navigator.appname.tolowercase().indexof("netscape") > -1) {

              theform = document.forms["form1"];

         }

         else {

              theform = document.form1;

         }

         theform.__eventtarget.value = eventtarget.split("$").join(":");

         theform.__eventargument.value = eventargument;

         theform.submit();

     }

// -->

</script>

要使用頁面內(nèi)容中產(chǎn)生以上代碼,可以添加一個linkbutton控件(好像只有該控件可以??)

另外的方法是在page_load()加上下面方法:

this.page.getpostbackeventreference(button1);

上面方法將觸發(fā)產(chǎn)生__dopostback()的javascript代碼,msdn中的解釋是:

“獲取對客戶端腳本函數(shù)的引用,調(diào)用該函數(shù)將使用服務(wù)器發(fā)送回該頁”

以上代碼可以應(yīng)用于在子窗口中修改數(shù)據(jù),然后刷新父窗口的情況

另外,注意“__dopostback()”,方法名中是兩道下劃線,并且區(qū)分大小寫。


 

8遇到的問題:

關(guān)于.net及sqlserver中的日期類型

解決方法:

例子:northwind--employees--birthdate

this.textbox1.text =dr.getdatetime(0).tostring();輸出:1948-12-8 0:00:00

this.textbox1.text =dr[0].tostring();輸出:1948-12-8 0:00:00

this.textbox1.text=dr.getdatetime(0).toshortdatestring();輸出:1948-12-8

this.textbox1.text=dr.getdatetime(0).tostring("yyyy#mm#dd");輸出:1948#00#08


  在裝了vs2003以后 從新裝了iis后需要注冊asp.net 不然提示說不是asp.net
:/documents and settings/administrator>c:/winnt/microsoft.net/framework/v1.1.43
2/aspnet_regiis -i
開始安裝 asp.net (1.1.4322.0)。
已安裝完 asp.net (1.1.4322.0)。


  9遇到的問題:

關(guān)于腳本的調(diào)試

解決方法:

1調(diào)整ie選項--高級--取消“禁止腳本調(diào)試”

2直接運(yùn)行你將要調(diào)試的aspx頁面

3當(dāng)頁面呈現(xiàn)完成時,回到vs.net中,調(diào)試--窗口--運(yùn)行文檔,窗口右側(cè)將出現(xiàn)當(dāng)前ie中的aspx頁面的名稱,雙擊它,此時頁面的html源文件將顯示在vs.net的窗口中,這樣就可以在html文件中設(shè)置斷點。


 

0遇到的問題:

關(guān)于存儲過程的調(diào)試

解決方法:

在查詢分析器中展開左側(cè)的對象瀏覽器(按f8,或“工具”--“對象瀏覽器”打開),展開存儲過程,選擇要調(diào)試的存儲過程,右鍵,調(diào)試/debug

如果存儲過程存在輸入?yún)?shù),則輸入測試參數(shù)值,即可進(jìn)行調(diào)試界面,f11單步


<form action="http://www.baidu.com/baidu" target="_blank">
            <div align="center">
                <input name="tn" type="hidden" value="baidu"> <a ><img src="/uploadpic/2007-5/200756235642142.gif" alt="baidu" align="bottom"
                        border="0"></a> <input type="text" name="word" size="30"> <input type="submit" value="百度搜索">
            </div>
        </form>

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 通河县| 怀化市| 上林县| 务川| 徐州市| 沅江市| 新野县| 通化县| 松原市| 南投市| 莱芜市| 东光县| 安福县| 黄山市| 淳安县| 芷江| 朝阳市| 凤台县| 盘山县| 榕江县| 武威市| 五峰| 淮滨县| 同心县| 论坛| 翼城县| 丹东市| 永寿县| 鲁山县| 屏东县| 襄垣县| 林州市| 民权县| 内丘县| 巫山县| 宁海县| 东乡县| 长治市| 廉江市| 万荣县| 承德县|