is it possible to Postback only Specific tools?
up vote
3
down vote
favorite
On my aspx page there are entry form with 10 text boxes,
1 drop-down(auto postback = true)
and two buttons.
dropdown SelectedIndexChanged fills two text box value.
button1 name: "add" & button2 name:"update"
On page load "update" visible = false
when click on "edit" from gridview, "add" visible = false
and
"update" visible = true.
because of default page load "update" visible = false
when i change drop-down,
"update" button invisible.
So is it possible to Postback only Specific tools(in my case textbox) ?
Currently i am try with below code behind dropdown (i know it's crazy)
if (addbtn.Visible == true) {Button2.Visible = false;}
else if (addbtn.Visible == false) { Button2.Visible = true;}
page load
protected void Page_Load(object sender, EventArgs e)
{
TextBox15.Enabled = false;
TextBox16.Enabled = false;
Button2.Visible = false;
if (!IsPostBack)
{
bind_dropdown();
}
}
GridView rowcommand
protected void GridView1_RowCommand1(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "editform")
{
addbtn.Visible = false;
Button2.Visible = true;
}
bind dropdown
private void bind_dropdown()
{
DropDownList1.DataTextField = "CITYNAME";
DropDownList1.DataValueField = "AID";
DropDownList1.DataBind();
}
dropdown change event
protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e)
{
if (addbtn.Visible == true)
{
Button2.Visible = false;
}
else if (addbtn.Visible == false)
{
Button2.Visible = true;
}
if (DropDownList1.SelectedIndex == 0)
{
TextBox15.Text = "";
TextBox16.Text = "";
}
else
{
try
{
c# asp.net
add a comment |
up vote
3
down vote
favorite
On my aspx page there are entry form with 10 text boxes,
1 drop-down(auto postback = true)
and two buttons.
dropdown SelectedIndexChanged fills two text box value.
button1 name: "add" & button2 name:"update"
On page load "update" visible = false
when click on "edit" from gridview, "add" visible = false
and
"update" visible = true.
because of default page load "update" visible = false
when i change drop-down,
"update" button invisible.
So is it possible to Postback only Specific tools(in my case textbox) ?
Currently i am try with below code behind dropdown (i know it's crazy)
if (addbtn.Visible == true) {Button2.Visible = false;}
else if (addbtn.Visible == false) { Button2.Visible = true;}
page load
protected void Page_Load(object sender, EventArgs e)
{
TextBox15.Enabled = false;
TextBox16.Enabled = false;
Button2.Visible = false;
if (!IsPostBack)
{
bind_dropdown();
}
}
GridView rowcommand
protected void GridView1_RowCommand1(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "editform")
{
addbtn.Visible = false;
Button2.Visible = true;
}
bind dropdown
private void bind_dropdown()
{
DropDownList1.DataTextField = "CITYNAME";
DropDownList1.DataValueField = "AID";
DropDownList1.DataBind();
}
dropdown change event
protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e)
{
if (addbtn.Visible == true)
{
Button2.Visible = false;
}
else if (addbtn.Visible == false)
{
Button2.Visible = true;
}
if (DropDownList1.SelectedIndex == 0)
{
TextBox15.Text = "";
TextBox16.Text = "";
}
else
{
try
{
c# asp.net
Button2.Visible = !addbtn.Visible
– phuzi
5 hours ago
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
On my aspx page there are entry form with 10 text boxes,
1 drop-down(auto postback = true)
and two buttons.
dropdown SelectedIndexChanged fills two text box value.
button1 name: "add" & button2 name:"update"
On page load "update" visible = false
when click on "edit" from gridview, "add" visible = false
and
"update" visible = true.
because of default page load "update" visible = false
when i change drop-down,
"update" button invisible.
So is it possible to Postback only Specific tools(in my case textbox) ?
Currently i am try with below code behind dropdown (i know it's crazy)
if (addbtn.Visible == true) {Button2.Visible = false;}
else if (addbtn.Visible == false) { Button2.Visible = true;}
page load
protected void Page_Load(object sender, EventArgs e)
{
TextBox15.Enabled = false;
TextBox16.Enabled = false;
Button2.Visible = false;
if (!IsPostBack)
{
bind_dropdown();
}
}
GridView rowcommand
protected void GridView1_RowCommand1(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "editform")
{
addbtn.Visible = false;
Button2.Visible = true;
}
bind dropdown
private void bind_dropdown()
{
DropDownList1.DataTextField = "CITYNAME";
DropDownList1.DataValueField = "AID";
DropDownList1.DataBind();
}
dropdown change event
protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e)
{
if (addbtn.Visible == true)
{
Button2.Visible = false;
}
else if (addbtn.Visible == false)
{
Button2.Visible = true;
}
if (DropDownList1.SelectedIndex == 0)
{
TextBox15.Text = "";
TextBox16.Text = "";
}
else
{
try
{
c# asp.net
On my aspx page there are entry form with 10 text boxes,
1 drop-down(auto postback = true)
and two buttons.
dropdown SelectedIndexChanged fills two text box value.
button1 name: "add" & button2 name:"update"
On page load "update" visible = false
when click on "edit" from gridview, "add" visible = false
and
"update" visible = true.
because of default page load "update" visible = false
when i change drop-down,
"update" button invisible.
So is it possible to Postback only Specific tools(in my case textbox) ?
Currently i am try with below code behind dropdown (i know it's crazy)
if (addbtn.Visible == true) {Button2.Visible = false;}
else if (addbtn.Visible == false) { Button2.Visible = true;}
page load
protected void Page_Load(object sender, EventArgs e)
{
TextBox15.Enabled = false;
TextBox16.Enabled = false;
Button2.Visible = false;
if (!IsPostBack)
{
bind_dropdown();
}
}
GridView rowcommand
protected void GridView1_RowCommand1(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "editform")
{
addbtn.Visible = false;
Button2.Visible = true;
}
bind dropdown
private void bind_dropdown()
{
DropDownList1.DataTextField = "CITYNAME";
DropDownList1.DataValueField = "AID";
DropDownList1.DataBind();
}
dropdown change event
protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e)
{
if (addbtn.Visible == true)
{
Button2.Visible = false;
}
else if (addbtn.Visible == false)
{
Button2.Visible = true;
}
if (DropDownList1.SelectedIndex == 0)
{
TextBox15.Text = "";
TextBox16.Text = "";
}
else
{
try
{
c# asp.net
c# asp.net
edited 3 hours ago
asked 9 hours ago
ronak6985
163
163
Button2.Visible = !addbtn.Visible
– phuzi
5 hours ago
add a comment |
Button2.Visible = !addbtn.Visible
– phuzi
5 hours ago
Button2.Visible = !addbtn.Visible
– phuzi
5 hours ago
Button2.Visible = !addbtn.Visible
– phuzi
5 hours ago
add a comment |
3 Answers
3
active
oldest
votes
up vote
1
down vote
As you don't give your code I can only guess what you're trying to achieve.
The best way to deal with this kind of problem is probably using AJAX as MKH proposed.
If you don't want to deal with AJAX you can also do it this way :
<form id="form1" runat="server">
<div>
<asp:DropDownList runat="server" ID="ddown" OnSelectedIndexChanged="ddown_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
<asp:TextBox runat="server" ID="tb"></asp:TextBox>
<asp:LinkButton runat="server" ID="btn" OnClick="btn_Click"></asp:LinkButton>
</div>
</form>
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ddown.Items.Add(new ListItem("Default", "-1"));
ddown.Items.Add(new ListItem("text 0", "0"));
ddown.Items.Add(new ListItem("text 1", "1"));
ddown.Items.Add(new ListItem("text 2", "2"));
}
}
protected void btn_Click(object sender, EventArgs e)
{
}
protected void ddown_SelectedIndexChanged(object sender, EventArgs e)
{
tb.Text = ddown.SelectedItem.Text;
btn.Visible = false;
}
This way, you put in the "If(!Page.IsPostBack)" only the code that must be init once.
Then with the you can manage the "Visible" part from SelectedIndexChanged.
THis answer is not complete as I didn't totally understand what you need but that can be a piece of answer if AJAX scares you ;)
thanks. i am already managing using btn.Visible = false; and btn.Visible = true;
– ronak6985
4 hours ago
I don't think the problem is on your Visible/Hide management but more on where you use them and how you deal with Postback. Could you share your code so we can help ?
– Grégory L
4 hours ago
i have updated my question with code.
– ronak6985
3 hours ago
If I understand well, your problem is that the page load put the button update back to invisible ? In this case why don't you put the "visible = false" in the If(!Page.IsPostBack) ?
– Grégory L
1 hour ago
And actually I would suggest to put also the textbox disable in the condition too.
– Grégory L
1 hour ago
add a comment |
up vote
0
down vote
Use AJAX , please take a look at Partial PostBack using UpdatePanel and ScriptManager Control Overview posts to implement it.
add a comment |
up vote
0
down vote
Ajax, or update panel will do the trick, if you want to solve this with pure code behind, passing correct parameter to determine the layout can be done with validate the parameters and toggle the visible attribute in the page load.
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
As you don't give your code I can only guess what you're trying to achieve.
The best way to deal with this kind of problem is probably using AJAX as MKH proposed.
If you don't want to deal with AJAX you can also do it this way :
<form id="form1" runat="server">
<div>
<asp:DropDownList runat="server" ID="ddown" OnSelectedIndexChanged="ddown_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
<asp:TextBox runat="server" ID="tb"></asp:TextBox>
<asp:LinkButton runat="server" ID="btn" OnClick="btn_Click"></asp:LinkButton>
</div>
</form>
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ddown.Items.Add(new ListItem("Default", "-1"));
ddown.Items.Add(new ListItem("text 0", "0"));
ddown.Items.Add(new ListItem("text 1", "1"));
ddown.Items.Add(new ListItem("text 2", "2"));
}
}
protected void btn_Click(object sender, EventArgs e)
{
}
protected void ddown_SelectedIndexChanged(object sender, EventArgs e)
{
tb.Text = ddown.SelectedItem.Text;
btn.Visible = false;
}
This way, you put in the "If(!Page.IsPostBack)" only the code that must be init once.
Then with the you can manage the "Visible" part from SelectedIndexChanged.
THis answer is not complete as I didn't totally understand what you need but that can be a piece of answer if AJAX scares you ;)
thanks. i am already managing using btn.Visible = false; and btn.Visible = true;
– ronak6985
4 hours ago
I don't think the problem is on your Visible/Hide management but more on where you use them and how you deal with Postback. Could you share your code so we can help ?
– Grégory L
4 hours ago
i have updated my question with code.
– ronak6985
3 hours ago
If I understand well, your problem is that the page load put the button update back to invisible ? In this case why don't you put the "visible = false" in the If(!Page.IsPostBack) ?
– Grégory L
1 hour ago
And actually I would suggest to put also the textbox disable in the condition too.
– Grégory L
1 hour ago
add a comment |
up vote
1
down vote
As you don't give your code I can only guess what you're trying to achieve.
The best way to deal with this kind of problem is probably using AJAX as MKH proposed.
If you don't want to deal with AJAX you can also do it this way :
<form id="form1" runat="server">
<div>
<asp:DropDownList runat="server" ID="ddown" OnSelectedIndexChanged="ddown_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
<asp:TextBox runat="server" ID="tb"></asp:TextBox>
<asp:LinkButton runat="server" ID="btn" OnClick="btn_Click"></asp:LinkButton>
</div>
</form>
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ddown.Items.Add(new ListItem("Default", "-1"));
ddown.Items.Add(new ListItem("text 0", "0"));
ddown.Items.Add(new ListItem("text 1", "1"));
ddown.Items.Add(new ListItem("text 2", "2"));
}
}
protected void btn_Click(object sender, EventArgs e)
{
}
protected void ddown_SelectedIndexChanged(object sender, EventArgs e)
{
tb.Text = ddown.SelectedItem.Text;
btn.Visible = false;
}
This way, you put in the "If(!Page.IsPostBack)" only the code that must be init once.
Then with the you can manage the "Visible" part from SelectedIndexChanged.
THis answer is not complete as I didn't totally understand what you need but that can be a piece of answer if AJAX scares you ;)
thanks. i am already managing using btn.Visible = false; and btn.Visible = true;
– ronak6985
4 hours ago
I don't think the problem is on your Visible/Hide management but more on where you use them and how you deal with Postback. Could you share your code so we can help ?
– Grégory L
4 hours ago
i have updated my question with code.
– ronak6985
3 hours ago
If I understand well, your problem is that the page load put the button update back to invisible ? In this case why don't you put the "visible = false" in the If(!Page.IsPostBack) ?
– Grégory L
1 hour ago
And actually I would suggest to put also the textbox disable in the condition too.
– Grégory L
1 hour ago
add a comment |
up vote
1
down vote
up vote
1
down vote
As you don't give your code I can only guess what you're trying to achieve.
The best way to deal with this kind of problem is probably using AJAX as MKH proposed.
If you don't want to deal with AJAX you can also do it this way :
<form id="form1" runat="server">
<div>
<asp:DropDownList runat="server" ID="ddown" OnSelectedIndexChanged="ddown_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
<asp:TextBox runat="server" ID="tb"></asp:TextBox>
<asp:LinkButton runat="server" ID="btn" OnClick="btn_Click"></asp:LinkButton>
</div>
</form>
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ddown.Items.Add(new ListItem("Default", "-1"));
ddown.Items.Add(new ListItem("text 0", "0"));
ddown.Items.Add(new ListItem("text 1", "1"));
ddown.Items.Add(new ListItem("text 2", "2"));
}
}
protected void btn_Click(object sender, EventArgs e)
{
}
protected void ddown_SelectedIndexChanged(object sender, EventArgs e)
{
tb.Text = ddown.SelectedItem.Text;
btn.Visible = false;
}
This way, you put in the "If(!Page.IsPostBack)" only the code that must be init once.
Then with the you can manage the "Visible" part from SelectedIndexChanged.
THis answer is not complete as I didn't totally understand what you need but that can be a piece of answer if AJAX scares you ;)
As you don't give your code I can only guess what you're trying to achieve.
The best way to deal with this kind of problem is probably using AJAX as MKH proposed.
If you don't want to deal with AJAX you can also do it this way :
<form id="form1" runat="server">
<div>
<asp:DropDownList runat="server" ID="ddown" OnSelectedIndexChanged="ddown_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
<asp:TextBox runat="server" ID="tb"></asp:TextBox>
<asp:LinkButton runat="server" ID="btn" OnClick="btn_Click"></asp:LinkButton>
</div>
</form>
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ddown.Items.Add(new ListItem("Default", "-1"));
ddown.Items.Add(new ListItem("text 0", "0"));
ddown.Items.Add(new ListItem("text 1", "1"));
ddown.Items.Add(new ListItem("text 2", "2"));
}
}
protected void btn_Click(object sender, EventArgs e)
{
}
protected void ddown_SelectedIndexChanged(object sender, EventArgs e)
{
tb.Text = ddown.SelectedItem.Text;
btn.Visible = false;
}
This way, you put in the "If(!Page.IsPostBack)" only the code that must be init once.
Then with the you can manage the "Visible" part from SelectedIndexChanged.
THis answer is not complete as I didn't totally understand what you need but that can be a piece of answer if AJAX scares you ;)
answered 5 hours ago
Grégory L
106111
106111
thanks. i am already managing using btn.Visible = false; and btn.Visible = true;
– ronak6985
4 hours ago
I don't think the problem is on your Visible/Hide management but more on where you use them and how you deal with Postback. Could you share your code so we can help ?
– Grégory L
4 hours ago
i have updated my question with code.
– ronak6985
3 hours ago
If I understand well, your problem is that the page load put the button update back to invisible ? In this case why don't you put the "visible = false" in the If(!Page.IsPostBack) ?
– Grégory L
1 hour ago
And actually I would suggest to put also the textbox disable in the condition too.
– Grégory L
1 hour ago
add a comment |
thanks. i am already managing using btn.Visible = false; and btn.Visible = true;
– ronak6985
4 hours ago
I don't think the problem is on your Visible/Hide management but more on where you use them and how you deal with Postback. Could you share your code so we can help ?
– Grégory L
4 hours ago
i have updated my question with code.
– ronak6985
3 hours ago
If I understand well, your problem is that the page load put the button update back to invisible ? In this case why don't you put the "visible = false" in the If(!Page.IsPostBack) ?
– Grégory L
1 hour ago
And actually I would suggest to put also the textbox disable in the condition too.
– Grégory L
1 hour ago
thanks. i am already managing using btn.Visible = false; and btn.Visible = true;
– ronak6985
4 hours ago
thanks. i am already managing using btn.Visible = false; and btn.Visible = true;
– ronak6985
4 hours ago
I don't think the problem is on your Visible/Hide management but more on where you use them and how you deal with Postback. Could you share your code so we can help ?
– Grégory L
4 hours ago
I don't think the problem is on your Visible/Hide management but more on where you use them and how you deal with Postback. Could you share your code so we can help ?
– Grégory L
4 hours ago
i have updated my question with code.
– ronak6985
3 hours ago
i have updated my question with code.
– ronak6985
3 hours ago
If I understand well, your problem is that the page load put the button update back to invisible ? In this case why don't you put the "visible = false" in the If(!Page.IsPostBack) ?
– Grégory L
1 hour ago
If I understand well, your problem is that the page load put the button update back to invisible ? In this case why don't you put the "visible = false" in the If(!Page.IsPostBack) ?
– Grégory L
1 hour ago
And actually I would suggest to put also the textbox disable in the condition too.
– Grégory L
1 hour ago
And actually I would suggest to put also the textbox disable in the condition too.
– Grégory L
1 hour ago
add a comment |
up vote
0
down vote
Use AJAX , please take a look at Partial PostBack using UpdatePanel and ScriptManager Control Overview posts to implement it.
add a comment |
up vote
0
down vote
Use AJAX , please take a look at Partial PostBack using UpdatePanel and ScriptManager Control Overview posts to implement it.
add a comment |
up vote
0
down vote
up vote
0
down vote
Use AJAX , please take a look at Partial PostBack using UpdatePanel and ScriptManager Control Overview posts to implement it.
Use AJAX , please take a look at Partial PostBack using UpdatePanel and ScriptManager Control Overview posts to implement it.
answered 5 hours ago
MKH
538
538
add a comment |
add a comment |
up vote
0
down vote
Ajax, or update panel will do the trick, if you want to solve this with pure code behind, passing correct parameter to determine the layout can be done with validate the parameters and toggle the visible attribute in the page load.
add a comment |
up vote
0
down vote
Ajax, or update panel will do the trick, if you want to solve this with pure code behind, passing correct parameter to determine the layout can be done with validate the parameters and toggle the visible attribute in the page load.
add a comment |
up vote
0
down vote
up vote
0
down vote
Ajax, or update panel will do the trick, if you want to solve this with pure code behind, passing correct parameter to determine the layout can be done with validate the parameters and toggle the visible attribute in the page load.
Ajax, or update panel will do the trick, if you want to solve this with pure code behind, passing correct parameter to determine the layout can be done with validate the parameters and toggle the visible attribute in the page load.
answered 5 hours ago
Chris
456
456
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53368776%2fis-it-possible-to-postback-only-specific-tools%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Button2.Visible = !addbtn.Visible
– phuzi
5 hours ago