Reputation: 325
I have a vb.net page and on the page is a select box. When someone changes the selected item in the select box, some fancy javascript fires to put the selected value into a hidden form at the bottom of the page and submit that value back to the page.
<script>
function cat(inForm){
document.getElementById('Cat_ID').value = inForm.Catechumen_ID.value;
document.getElementById('passCat').submit();
}
</script>
Based upon this postback, I want to update the page to be based upon the value that was posted back to the page.
I added:
<script>
alert("postback: <%= Page.IsPostBack = true %>" );
</script>
to the page and it alerts me that isPostback is false on initial load and after postback. why?
Upvotes: 0
Views: 268
Reputation: 325
After thinking about it, why ask if isPostBack = true, when I can simply ask if the variable I posted has a value.
if request.form("cat_ID") <> "" then
'isPostBack
else
'not isPostBack
end if
Upvotes: 1
Reputation: 21
You normally use 'is post back' page property in page load event for data bindings for controls such as grid view that use view state.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
' More coding will go here.
'--------------------------
End If
Upvotes: 0