I have a hierarchical 开发者_如何转开发structure and when the user press on Add a child, I reopen the same page with [Add, ParentID] parameters.
The problem is, after pressing Add, a postback is made and the reading for the querystring is made again because the querystring is still the same and I catch & process it in the page_load.
Note: I can't use IsPostBack
because the calling is from the same page, so it' always true
.
Any help!
Make sure you only process the query string when the page has not been posted back, by using the IsPostBack
property of Page
:
if(!IsPostBack)
{
//Process query string
}
If (!Page.isPostBack) {
//read your query string here
}
in the page load event or on you button click add this :
If Not IsPostBack Then
'your code here
End If
C#
if (!IsPostBack) {
//your code here
}
Using session
if (Session("ok") == 0) {
//some code
Session("ok") = 1;}
this will execute your query on the first load only !!!
in the page load event
add these code and see if it works
if ((!IsPostBack)&&(!IsCallBack)) {
//some code! }
if(!IsPostBack)
{
// Read the query string.
}
精彩评论