Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
Hi Friends,
I'm Having a textbox , Dropdownlist and Button in my aspx page.
When item is selected in dropdown list, I make textbox visible false by using javascript.
And,
in Button click im doing some validation and the alert will come if there is any validation failed.
 
My Problem is,
When I click button the alert is working fine but the textbox is visible (true) automatically.
I never write code to make textbox visible true in aspx.cs page.
But still its happening..
How to solve this?
Please help me on this...
Posted 5-May-11 20:57pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

hi
 
Here the problem is page postback
 
on page lode method u just check the
is(!page.postback)
textbox.visible=false;
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Its because ur page is posting back after validation
 
I suggest you to write visible property on your button click event like
 
textbox.visible=false;
 
and on page load write
 
textbox.visible=true;
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 8

protected void LinkButton1_Click(object sender, EventArgs e)
{
if (LinkButton1.Enabled == true)
{
TextBox1.Visible = true;
Button1.Visible = true;
}
}
 
protected void Button1_Click(object sender, EventArgs e)
{
if (Button1.Enabled == true)
{
TextBox1.Visible = false;
}
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Its because on click of your button, the page is making a postback. If you have not done any server side coding on that button, you can write a "return false;" statement in javascript to avoid postback. Or other wise, make the textbox visible false on codebehind of that button.
 
[Updated point]
While calling your method on click of button put a "return" before the method name, and "return false" at the end of your javascript. This will do.
[/updated point]
 

Anurag
  Permalink  
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I think your page gets postback when you respond to alert message.
Just give return false after your alert in Javascript.
That will stop the postback.
 
- Happy programming
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Hi,
I have added "return false;" in javascript . But still there is same problem..
  Permalink  
Comments
@nuraGGupt@ at 6-May-11 3:00am
   
You need to provide any additional information by editing your question only. You do not need to add a new solution here for this. (See my updated answer for this problem.)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

Check Ispostback on page lode.
 
Take one hidden field set value using js when user click on drop down list box set it to true.(set default value false)
and on page lode evet check that hidden value field if its value is false then not view your text box.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 7

write the code set visible(false) of textbox during postback, so that every time u click on the button textbox ll b invisible..k
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 350
1 Jochen Arndt 150
2 Richard MacCutchan 135
3 Andreas Gieriet 100
4 DamithSL 95
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,260


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 2 Jul 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100