點擊一個按鈕後,我調用一個JavaScript函數。獲得該值後,我需要從代碼隱藏中獲得的值執行一些操作。我應該如何調用代碼隱藏?從Javascript調用代碼隱藏
我的aspx:
function openWindow(page) {
var getval = window.showModalDialog(page);
document.getElementById("<%= TxtInput.ClientID %>").value = getval;
//After this I need to perform stuff 'Upload(TxtInput.value)' into database from the code-behind
}
按鈕調用的功能被設置以下述方式:
<button class="doActionButton" id="btnSelectImage" runat="server" onclick="openWindow('../rcwksheet/popups/uploader.htm')">Select Image</button>
我期望的碼後面(VB):
Public Sub btnSaveImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelectImage.ServerClick
Dim inputFile As String = Me.TxtInput.Value
//do more stuff here
End Sub
所以:
- 有沒有辦法從JavaScript調用代碼隱藏?
- 我可以以某種方式使用按鈕的「onclick」屬性首先轉到JavaScript,然後轉到代碼隱藏?
- 觸發TxtInput.Value的代碼隱藏調用「onchange」?
如果你使用網絡服務像加斯帕建議,請確保您知道如何保護您的Web服務。 http://stackoverflow.com/questions/4264909/asp-net-is-my-web-service-secure-enough –