我有一个aspx页面。
DROPDOWN的所选价值已经失去。
当我点击搜索时,我可以执行服务器端事件并返回页面,一切正常。当我按下更新时,遗憾的是,我的组合框失去了它们的价值。对于母版页和当前页面甚至所有控件都有enbabledViewState为true。我有什么想法可以开始接近这个吗?当我们到达page_load事件时,这些值就消失了。没有其他生命周期事件。
Page_Load()
{
if(!PostBack)
{
//Populate a dropdown.
This is where the dropdown is safely populated.
}
}
btnClickSearch()
{
}
btnClickUpdate()
{
}
页面上的两个按钮。
不工作
<asp:Button id="btnUpdate" class="fg-button ui-state-default ui-corner-all" runat="server" Text="Update" onclick="btnClick_Update" onclientclick="return updateNotes();" style="width:auto;"/>
WORKING
<asp:Button id="A2" runat="server" onclick="btnClick_Submit" OnClientClick="return searchNotes();" class="fg-button ui-state-default ui-corner-all" style="float: left; margin-left: 20px; width:auto;" Text="Search"></asp:Button>
两个按钮的onclient单击事件都会调用blockUI并返回true。知道为什么这些行为会有所不同吗?
此外,所有下拉项目都没有重复值。
答案 0 :(得分:2)
按下更新按钮后,也许您可以尝试为选定的会话设置会话:
btnClickUpdate()
{
Session["DDLValue"] = dropdownlist.SelectedValue;
}
在页面加载时,获取会话并将其设置为下拉列表(如果它不是NULL:
)if(Session["DDLValue"] != null)
{
dropdownlist.SelectedValue = Session["DDLValue"].ToString();
}
答案 1 :(得分:0)
我有两个控件。
Button1和button2。按钮1工作正常。按钮2确实调用它的服务器端事件,但是当发生这种情况时,我们得到一个CKEditor解集。
我有一个包含CKEditor和asp按钮的jquery UI对话框。单击此按钮时,服务器端的所有值都将丢失,并显示反汇编。
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="ckeditor/custom/dialog-patch.js"></script>
<span style="width: 500px; height: 100%">
<CKEditor:CkEditorControl id="CKEditor1" runat="server" AutoPostBack="false">
</CKEditor:CkEditorControl>
</span>
定义
$(function() {
// to load editor
CKEDITOR.on('dialogDefinition', function(ev) {
// Take the dialog name and its definition from the event
// data.
var dialogName = ev.data.name;
var dialogDefinition = ev.data.definition;
// Check if the definition is from the dialog we're
// interested on (the "Link" dialog).
if (dialogName == 'link') {
// remove contents
dialogDefinition.removeContents('target');
dialogDefinition.removeContents('upload');
dialogDefinition.removeContents('advanced');
// Get a reference to the "Link Info" tab.
var infoTab = dialogDefinition.getContents('info');
// Remove the "Link Type" combo and the "Browser
// Server" button from the "info" tab.
infoTab.remove('linkType');
infoTab.remove('browse');
}
else if (dialogName == 'table') {
// Get a reference to the default tab.
var infoTab = dialogDefinition.getContents('info');
infoTab.remove('selHeaders');
infoTab.remove('txtHeight');
infoTab.remove('txtCellSpace');
infoTab.remove('txtCellPad');
infoTab.remove('txtCaption');
infoTab.remove('txtSummary');
infoTab.remove('cmbAlign');
}
});
});
打开包含CKEditor的对话框的函数。
function EditDialog(element,supplier,codeId,name, category,categoryCode, noteId,templateText) {
var numberOfNotes = $(element).parent().children('.text').length;
var noteBody = "";
if (numberOfNotes == 1) {
noteBody = $(element).parent().children('.text').html();
}
if (noteBody == "") {
noteBody = templateText;
}
$('#<%=esupplier.ClientID %>').val(supplier);
$('#<%=ename.ClientID %>').val(name);
$('#<%=enotecategory.ClientID %>').val(category);
$('#<%=hfCategoryCode.ClientID %>').val(categoryCode);
$('#<%=hfNoteID.ClientID %>').val(noteId);
$('#<%=hfIdCode.ClientID %>').val(codeId);
var dialogeditcontainer = $('#editdialog').dialog('open');
dialogeditcontainer.parent().appendTo(jQuery('form:first'));
CKEDITOR.instances[$('#editorName').val()].setData(noteBody);
return false;
}
定义
$(function() {
// to load editor
CKEDITOR.on('dialogDefinition', function(ev) {
// Take the dialog name and its definition from the event
// data.
var dialogName = ev.data.name;
var dialogDefinition = ev.data.definition;
// Check if the definition is from the dialog we're
// interested on (the "Link" dialog).
if (dialogName == 'link') {
// remove contents
dialogDefinition.removeContents('target');
dialogDefinition.removeContents('upload');
dialogDefinition.removeContents('advanced');
// Get a reference to the "Link Info" tab.
var infoTab = dialogDefinition.getContents('info');
// Remove the "Link Type" combo and the "Browser
// Server" button from the "info" tab.
infoTab.remove('linkType');
infoTab.remove('browse');
}
else if (dialogName == 'table') {
// Get a reference to the default tab.
var infoTab = dialogDefinition.getContents('info');
infoTab.remove('selHeaders');
infoTab.remove('txtHeight');
infoTab.remove('txtCellSpace');
infoTab.remove('txtCellPad');
infoTab.remove('txtCaption');
infoTab.remove('txtSummary');
infoTab.remove('cmbAlign');
}
});
});
最后是两个aspx按钮。第一个起作用,第二个起作用。第二个按钮位于与ckeditor的对话框中。
这一项工作。
<asp:Button id="A2" runat="server" onclick="btnClick_Submit" OnClientClick="return searchNotes();" class="fg-button ui-state-default ui-corner-all" style="float: left; margin-left: 20px; width:auto;" Text="Search"></asp:Button>
这一个没有
<asp:Button id="btnUpdate" runat="server" onclick="btnClick_Update" onclientclick="return updateNotes();" style="width:auto;" Text="Update" class="fg-button ui-state-default ui-corner-all" />
两个onclientclick事件调用BlockUI都返回true。
答案 2 :(得分:-1)
尝试填充,如果它也是回发..
if(!Page.IsPostBack || Page.IsPostBack)
{
//Populate a dropdown.
This is where the dropdown is safely populated.
}
参考... Page.IsPostBack Property