2011-10-11 58 views
0

我有一個母版頁和其他asp.net表單上我需要調用一個方法來.ashx的文件的東西,如下圖所示:如何在Asp.Net母版頁上使用POST方法?

由於我有作爲任何按鈕我點擊它的發佈按鈕問題返回我不想要的內容。

<form id="Form1" action="Upload.ashx" method="POST" enctype="multipart/form-data" 
    runat="server"> 
    <asp:ScriptManager ID="ScriptManager1" runat="server"> 
    </asp:ScriptManager> 
    <div id="fileupload" style="border: thin solid #666666; width: 600px; height: 520px; 
     z-index: 1; left: 18px; top: 22px; position: absolute; overflow: auto;"> 
     <div class="fileupload-buttonbar"> 
      <label class="fileinput-button"> 
       <span>Add files...</span> 
       <input type="file" name="files[]" multiple="multiple" /> 
      </label> 
      <button type="submit" class="start"> 
       Start upload</button> 
      <button type="reset" class="cancel"> 
       Cancel upload</button> 
      <button type="button" class="delete"> 
       Delete all files</button> 
      <div class="fileupload-progressbar"> 
      </div> 
     </div> 
     <div class="fileupload-content" style="border-style: none"> 
      <table class="files"> 
      </table> 
      </div> 
     </div> 
</form> 

這是不可能的,因爲我有一個內容頁面。

那麼我該如何做到基於母版頁的asp.net表單的內容。

+0

「master page and other form」?你想做什麼?你可能正在嘗試做些什麼,而且你對這個問題的看法在asp.net和母版頁面上是完全錯誤的 –

+0

是的,我只是試圖展示我現在擁有的窗體,並且在窗體上有一個窗體而且我正在處理主頁,所以我如何處理主頁是我的疑問! – coder

+0

我已更新我的問題。 – coder

回答

1

您不能將服務器端表單標籤發佈到其他頁面。服務器端表單控件被設計爲回發到自我(它忽略動作屬性) - 這就是爲什麼你看到你的頁面被髮布到(內容)頁面。母版頁不是一個真正的頁面,而是一個模板/佈局 - 內容頁面表示實際的頁面(母版頁實際上是一個控制樹被合併到內容頁面樹中的控件)。

您還可以使用服務器端按鈕控件cross-page posting in ASP.NET

但是,我相信無論你試圖達到什麼目的,你都需要創建一個單獨的 html表單標籤。例如,

... 

<!-- server side form - do not touch --> 
<form id="Form1" runat="server"> 
... 
</form> 

... 

<!-- you can have multiple html form tags but you cannot use server controls --> 
<form action="Upload.ashx" method="POST" enctype="multipart/form-data"> 
... 
</form> 

... 
+0

感謝您的回覆,該鏈接正是我現在看到的! – coder