我已經在站點母版頁上編寫了Javascript代碼。但是,當我打電話給Javascirpts時,它不起作用。任何人都可以幫我弄明白嗎?謝謝Page.ClientScript.RegisterStartupScript不起作用
以下是站點母版頁中的Javascript代碼。
<head id="Head1" runat="server">
<title></title>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="/Styles/jquery-ui-1.9.2.custom.min.css" />
<script type="text/javascript" src="/Scripts/jquery-1.8.3.js"></script>
<script type="text/javascript" src="/Scripts/jquery-ui-1.9.2.custom.min.js"></script>
<script type="text/javascript">
function dialog(text) {
$("#text").text(text);
$("#dialog-message").dialog
({
buttons: {
close: function() { $(this).dialog("close"); }
}
});
};
function dialogWithRedirect(text, url) {
$("#text").text(text);
$("#dialog-message").dialog
({
buttons: {
close: function() { location.href = url; $(this).dialog("close"); }
}
});
};
var confirmed = false;
function confirmDialog(obj, text) {
if (!confirmed) {
$("#text").text(text);
$("#dialog-message").dialog({
buttons: {
"Confirm": function() {
$(this).dialog("close");
confirmed = true;
obj.click();
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
return confirmed;
};
</script>
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
</asp:ContentPlaceHolder>
這是我如何調用Javascript角。
protected void ImageButtonOK_Click(object sender, ImageClickEventArgs e)
{
if (tbFirstName.Text != "" && tbLastName.Text != "" && tbNickName.Text != "" && tbUsername.Text != "" && tbPassword.Text != "" && tbConfirmPassword.Text != "")
{
if (validateUsername())
{
Database database = new Database();
string sql = "INSERT INTO users " +
" (user_id " +
" ,first_name " +
" ,last_name " +
" ,nickname " +
" ,image " +
" ,username " +
" ,password) " +
" VALUES " +
" (" + user_id + " " +
" ,'" + tbFirstName.Text + "' " +
" ,'" + tbLastName.Text + "' " +
" ,'" + tbNickName.Text + "' " +
" ,'" + pictureFile + "' " +
" ,'" + tbUsername.Text + "' " +
" ,'" + tbPassword.Text + "')";
database.executeNonQuery(sql);
database.close();
Page.ClientScript.RegisterStartupScript(typeof(Page), "print", "<script type='text/javascript'> dialogWithRedirect('Save complete','user.aspx');</script>");
}
}
else
{
Page.ClientScript.RegisterStartupScript(typeof(Page), "print", "<script type='text/javascript'> dialog('Please fill all required data');</script>");
}
}
爲什麼C標籤在這裏? – devnull