Showing posts with label button. Show all posts
Showing posts with label button. Show all posts

Saturday, March 31, 2012

Text Box

Hi,

I have an update button click event like this :

lblmessage.text = txtAuthor.text;

Even though I manually change the data in text box, somehow it does not show on to the label field.Whatever value I put in txtAuthor the label field is empty.

Any help is greatly appreciated. I hope I have framed my question properly.

With the semi-colon after the line, it looks like C#, so, just in case - what language are you using (VB or C#)?

augustwind:

With the semi-colon after the line, it looks like C#, so, just in case - what language are you using (VB or C#)?

I am using C#. Actually the updated data from the textbox goes to the property of an object. But when I found there was a problem I created a label control to see if the data is being read from the text box. But no data is being read from the text box.


Well - I don't really know what to tell you - it definitely should work.

Save it again - and rebuild - then run it, and put a break point at the code line and see if it ever hits that line.


Are u changing the value of the textbox in the page load, because that event is fired first.

Hope this helps

Thanks

Vikram

Vikram's Blog


Are you using Visual Web Developer? I have the same problem sometime when trying to get the values for update/.

Thanks


e_screw:

Are you using Visual Web Developer? I have the same problem sometime when trying to get the values for update/.

Thanks

I am using the Full blown edition of VS. I guess as Vikram suggested I am gonna have to check the code in the page load event.


Thanks a lot for the reply guys. I was able to fix the problem.

The problem was that I was pulling the data from the database in the page load event. And whenever I click the update button the original data from teh DB get loaded due to the page load event firing first. So there was no update taking place. Hence the label control which was pulling the data from the textbox was pulling the original data instead of the updated data... I hope I make sense in what I said.

I fixed it by adding the code for pulling data from the DB inside the " if (! IsPostBack) { } " block within the page load event. That fixed the problem in the test page that I created. I havent yet tested it on other pages that I am having trouble with. Hope fully I have resolved the problem. Thanks to Vikram for pointing out the Page Load event.

Text Box and Image Button

Hello,

I added a TextBox and an Image Button to a page so that they are side
by side.
Instead of both being top aligned the Text Box is pushed down.

Why is that?
How can I solve this?

Thanks,
MiguelHi there again,

<asp:ImageButton ID="ImageButton1" runat="server" ImageAlign="Top" />
<asp:TextBox ID="TextBox2" runat="server" />

or

<table>
<tr>
<td valign="top">
<asp:ImageButton ID="ImageButton2" runat="server" />
</td>
<td valign="top">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
</table>

or

<div>
<div style="float:left">
<asp:ImageButton ID="ImageButton3" runat="server" />
</div>
<asp:TextBox ID="TextBox3" runat="server" />
</div>
--
Milosz

"shapper" wrote:

Quote:

Originally Posted by

Hello,
>
I added a TextBox and an Image Button to a page so that they are side
by side.
Instead of both being top aligned the Text Box is pushed down.
>
Why is that?
How can I solve this?
>
Thanks,
Miguel
>
>

Text Box and Image Button

Hello,
I added a TextBox and an Image Button to a page so that they are side
by side.
Instead of both being top aligned the Text Box is pushed down.
Why is that?
How can I solve this?
Thanks,
MiguelHi there again,
<asp:ImageButton ID="ImageButton1" runat="server" ImageAlign="Top" />
<asp:TextBox ID="TextBox2" runat="server" />
or
<table>
<tr>
<td valign="top">
<asp:ImageButton ID="ImageButton2" runat="server" />
</td>
<td valign="top">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
</table>
or
<div>
<div style="float:left">
<asp:ImageButton ID="ImageButton3" runat="server" />
</div>
<asp:TextBox ID="TextBox3" runat="server" />
</div>
--
Milosz
"shapper" wrote:

> Hello,
> I added a TextBox and an Image Button to a page so that they are side
> by side.
> Instead of both being top aligned the Text Box is pushed down.
> Why is that?
> How can I solve this?
> Thanks,
> Miguel
>

Text Box and submit button not visible on the browser

Hi,
I am new to this group and to ASP.Net. I wrote a simple .aspx program in VS.Net environment. It has a label control, TextBox control and a button control. When the page is viewed on the browser, one enters their name or whatever and click the submit button, the resulting page shoul display "Hello and the text from the text box. I added required code in the button click event. The problem is when the page is loaded first time on the browser, I see only the label contol with the text that I entered before. Text Box and the Button controls are not visible. Any clues??
thanks.do you have runat=server for both?
Make sure that you have runat="server" in the html for the textbox and button...and make sure you have not set the visible property to false

MajorCats
I do have runat="server" and the Visible properties are set to False. Still it is not working. any other clues?...
After playing around with the code, I realized that none of my web controls are visible in the browser. If I change the following code
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
to
<input type="text" id="TextBox1"> </input>
then, I see the text box.
But it is not useful when I am trying to build a page using the web controls.
Why is it none of my web controls are visible?.
Anyone know what is triggering this kind of behavior?
help please...... :(
..."and the Visible properties are set to False."

I am assuming you meant that the visible property is NOT set to false...or this is your problem.

Post your html and code...

MajorCats
Here is the code... None of my web controls are visible when loaded in the browser. When I change them to a normal <input> tag, then it displays. It is not useful, when I am trying to develop a web application in the .Net environment. Text box property is set to Tru to begin with and then changed later in the code. see the button_click event handler code. Any help is appreciated.
thanks.

Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents Button1 As System.Web.UI.WebControls.Button

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = "Hello. " & TextBox1.Text & "!"
TextBox1.Visible = False
Button1.Visible = False
End Sub
End Class

<%@. Page Language="vb" AutoEventWireup="false" Codebehind="Hello.aspx.vb" Inherits="Aerosea.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<P>
<asp:Label id="Label1" runat="server">Enter a Name:</asp:Label>
<asp:TextBox id="TextBox1" runat="server" Visible="False"></asp:TextBox>
<asp:Button id="Button1" runat="server" Text="Submit" Visible="False"></asp:Button></P>
</form>
</body>
</HTML
Your problem is the visible=false in your tag...

<asp:TextBox id="TextBox1" runat="server" Visible="False"></asp:TextBox
Change this to:

<asp:TextBox id="TextBox1" runat="server" Visible="True"></asp:TextBox
and it will show up.

Basically, your code shows that you are hiding your textbox and button, and if the button were visible and someone clicked it, you are hiding it yet again......

MajorCats
Thank you very much. I totally overlooked the HTML part and thought the problem was in the Code. I changed it, and now it works.
thanks.

text box commands...i think

ok, so i have a textbox and 5 buttons, 4 list different things, and one is the search button...

no when i click enter, and i have text in my tetbox, the page loads, but doesnt do anything, yet when i click search the search function runs..

how do i make it so when a user hits enter on there text box, it runs that function...

Thanks, JustinPlace a simple html textbox in your form, make it hidden.

<input type="text" style="display: none;">

This way, pressing enter should submit the form.
but i dont use <form method="post" action="blabla">

Thanks, Justin
You have to have a form on your page if you're going to make the page work.

Text box Display

I don't understand the Display setting for controls such as text boxes.
I have a text box a button next to it, and then a submit button below
everything so that when the 1st button is pressed, a calendar appears
underneath it.

Becasue the submit button is below all the user input stuff, I want to
make it so that the calendar and the submit buttons are given set
positions on the screen, so that whenever I press the 1st button, my
submit button doesn't get pushed down the screen to make way for the
calendar.

I would've thought Display="Static" would do this, but I get the same
result as using Display="Dynamic". Can anybody help me out with this?

Any help would be really appreciated.

Thanks,

Mike

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!You need to use absolute display but make sure the parent elements are all
setup - positioning elements in pixel offsets is not a very good thing to
do. Static is meant for something else and IE does not even support it.

Jerry

"Mike P" <mrp@.telcoelectronics.co.uk> wrote in message
news:OVZiJ#UmDHA.2772@.TK2MSFTNGP10.phx.gbl...
> I don't understand the Display setting for controls such as text boxes.
> I have a text box a button next to it, and then a submit button below
> everything so that when the 1st button is pressed, a calendar appears
> underneath it.
> Becasue the submit button is below all the user input stuff, I want to
> make it so that the calendar and the submit buttons are given set
> positions on the screen, so that whenever I press the 1st button, my
> submit button doesn't get pushed down the screen to make way for the
> calendar.
> I would've thought Display="Static" would do this, but I get the same
> result as using Display="Dynamic". Can anybody help me out with this?
>
> Any help would be really appreciated.
>
> Thanks,
> Mike
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

text box text wont change

i have a asp.net page that has some text boxes with some text in there..then i have a submit button..the problem is that when i try in code to get what the textboxes have in the .Text property i get what i've put when the page loaded and not what actually the user has written! anyone has experienced this? what am i doing wrong? :confused:

help!!!!!!!!!!!!!You just not checking for post back...like I said in the other thread, post your code (especially your load event code) and I will show you how to use it properly to ensure things like this don't happen.
load event
WebMessage web = Serializer.BinDeSerializer(Server.MapPath(@."Logs\" + Request.QueryString["File"]));
msgTxt.Text = web.Message;
titleTxt.Text = web.Title;
nickTxt.Text = web.Author;
post(edit)button
case "EDIT": {
Debug.WriteLine(titleTxt.Text);
string filename = Server.MapPath(@."Logs\" + Request.QueryString["File"]);
WebMessage oldMsg = Serializer.BinDeSerializer(filename);

if (File.Exists(filename)) {
File.Delete(filename);
}

WebMessage newMsg = new WebMessage(
titleTxt.Text,
msgTxt.Text,
nickTxt.Text,
DateTime.Now,
oldMsg.Comments,
Path.GetFileName(filename));

Serializer.BinSerialize(newMsg, filename);
Response.Redirect("Log.aspx?&Action=POST", true);
break;
where titleTxt,msgTxt,nickTxt are the TextBoxes which arent changing the text
In your page load event, check for Page.IsPostBack.

if (!Page.IsPostBack) {
// Perform your initialization (db calls, etc..)
}
still not working...i dont get what would help checkin if it is postback or not lol..because if it is postback and now is not working then checking for it wont help, if it isnt and isnt working by checking i will not do it work..so *** can i do?
Because we are working in a stateless environment. Everytime a postback occurs, the page_load event fires off before any of the control event(s) that caused the post back. So, if you reset the values in the load event, then in your event handler, you are still dealing with the initial default values.
Change to this:

if (!Page.IsPostBack)
{
WebMessage web = Serializer.BinDeSerializer(Server.MapPath(@."Logs\" + Request.QueryString["File"]));
msgTxt.Text = web.Message;
titleTxt.Text = web.Title;
nickTxt.Text = web.Author;
}
hmm...even with hellswraith code it doesnt work..
Well, the code I posted is the exact same, so it wouldn't work (minus the three lines of code) :rolleyes:

Post your entire code-behind, it's something else..
hmm my page is getting a bit confusing, since its only my 2nd asp.net project and i wasnt expecting for somethings i had to implement..i will make a new architecture for the site and then i will try again and if it doesnt work post it here again..but i need to implement cookies..anyone could answer by other post about cookies plz? :D

tks by ur answers btw

Wednesday, March 28, 2012

text box, command button and required field Validator

there is one text box, command button and one required
field validator control on a web form.
i want user to enter the data in text box i.e it is
mandatory field. so i had used required validator for
this purpose. all works perfectly it gave me the
message that please insert the data etc. but the
problem is that after that i want focus to be put back
on the control. [ please give me the solution keeping
in mind that there could be many such controls on the
form and i want to set focus on respective text box if
user doesn't enter the value for mandatory fiels ]If you want focus back on the textbox, you're in for a lot of work. Its not hard to put focus on the control using javascript, that's easy enough.

The problem stems from what you later ammend to your question (there could be many such controls). Ok... so if there's only one control, that control gets the focus. But if there are five, the fifth one will get focus (because each will apply focus, but the last one to attempt to do so will be the one that wins). And if the last control gets focus, what's the point really - you want it to be user friendly, and the user is going to want to start at the top, not at the bottom of the page.

So you now have a problem - how do you get focus on the first control on what could be a possible list of included controls. For that - you need a way to store the collection of the controls, and some code to determine which is the top-most (first rendered) control that flunked validation and requires focus.

You will need to tip-toe through the server-client architecture, using a combination of code-behind and javascript to do so.

If you wish to explore it further - you best describe more on what your control is (you mention a textbox, validator, and a button - button for each control or one button on the entire page?)

Text Changed Event for a button

There are two text box, one is from date and another is to date
textbox. Each text box having a calender popup button to select From
date and To date. Both text box having a TextChanged event
attached.There is one more text box named as No. of Days, No. of days
means the difference b/w from date and to date, to calculate the No. of
Days i have written the code in TextChanged event. When i am entering
date manually in both text box the TextChanged Event is working and i
am getting the no. of days. But when i am selecting a date from
calender popup, then the TextChanged Event is not working and i am not
getting the difference in No. of Days test box.Attach a server OnClick event to the popup button. Then on the server side
take values of From and To dates and calculate No.of Days. You should not
care whether the postback originated from TextChanged or OnClick event.

Eliyahu

"gaurav" <gauravsrivastava2003@.yahoo.com> wrote in message
news:1116421111.732062.97490@.f14g2000cwb.googlegro ups.com...
> There are two text box, one is from date and another is to date
> textbox. Each text box having a calender popup button to select From
> date and To date. Both text box having a TextChanged event
> attached.There is one more text box named as No. of Days, No. of days
> means the difference b/w from date and to date, to calculate the No. of
> Days i have written the code in TextChanged event. When i am entering
> date manually in both text box the TextChanged Event is working and i
> am getting the no. of days. But when i am selecting a date from
> calender popup, then the TextChanged Event is not working and i am not
> getting the difference in No. of Days test box.

Text Changed Event for a button

There are two text box, one is from date and another is to date
textbox. Each text box having a calender popup button to select From
date and To date. Both text box having a TextChanged event
attached.There is one more text box named as No. of Days, No. of days
means the difference b/w from date and to date, to calculate the No. of
Days i have written the code in TextChanged event. When i am entering
date manually in both text box the TextChanged Event is working and i
am getting the no. of days. But when i am selecting a date from
calender popup, then the TextChanged Event is not working and i am not
getting the difference in No. of Days test box.Attach a server OnClick event to the popup button. Then on the server side
take values of From and To dates and calculate No.of Days. You should not
care whether the postback originated from TextChanged or OnClick event.
Eliyahu
"gaurav" <gauravsrivastava2003@.yahoo.com> wrote in message
news:1116421111.732062.97490@.f14g2000cwb.googlegroups.com...
> There are two text box, one is from date and another is to date
> textbox. Each text box having a calender popup button to select From
> date and To date. Both text box having a TextChanged event
> attached.There is one more text box named as No. of Days, No. of days
> means the difference b/w from date and to date, to calculate the No. of
> Days i have written the code in TextChanged event. When i am entering
> date manually in both text box the TextChanged Event is working and i
> am getting the no. of days. But when i am selecting a date from
> calender popup, then the TextChanged Event is not working and i am not
> getting the difference in No. of Days test box.
>

Monday, March 26, 2012

Text in textbox enables button.

Hello beginner here.
I've been researching for awhile to find a way to enable a button when
text is entered into a textbox (client side). I working with asp.net
2.0 C#. I've been trying to figure this out through javascript or
someone told me to research Page.RegisterClientScriptBlock Method, but
I can't seem to figure this out. Any help will be appreciated.

ThanksHey.

in your html:
<script>
function blah(textbox,button)
{
button.disabled = textbox.value.length == 0;
}
</script>

in your C# (in page load handler or wherever):

...
this.txtBox.Attributes["onkeyup"] =
string.Format("blah(this,getElementByID('{0}'));",this.btnSubmitOrWhateverItsNameIs.ClientID);
...

Hope this helps.
Kikoz

<hledman@.gmail.comwrote in message
news:1154459595.292991.267130@.i42g2000cwa.googlegr oups.com...

Quote:

Originally Posted by

Hello beginner here.
I've been researching for awhile to find a way to enable a button when
text is entered into a textbox (client side). I working with asp.net
2.0 C#. I've been trying to figure this out through javascript or
someone told me to research Page.RegisterClientScriptBlock Method, but
I can't seem to figure this out. Any help will be appreciated.
>
Thanks
>

Saturday, March 24, 2012

Text on the button does not display

Hello,

I am new to Dot Net. In the following code, the text on the button does not display. However, if I add the following for the button control, it does display.

Text ="Confirm"

Also, instead of using <asp:/> I tried using the following and the text still did not display and I get the error message: "'Click' is not a member of 'ASP.SimpleForm_aspx'"

<p><button id="mybutton" OnServerClick="Click" runat="server"> Confirm</button></p>

<html>
<head>
...
</head>
<body>
<form runat="server">
<h2>Take the Survey!</h2>
<p>Name:<br />
<input type="text" id="txtName" runat="server" /></p>
<p>Email:<br />
<input type="text" id="txtEmail" runat="server" /></p>
<p>Which server technologies do you use?<br />
<select id="servermodel" runat="server" multiple="true">
<option>ASP.NET</option>
<option>JSP</option>
</select></p>
<p>Do you like .NET so far?<br />
<select id="likedotnet" runat="server">
<option selected>Yes</option>
<option>No</option>
</select></p>
<asp:button id="mybutton" OnServerClick="Click" Confirm runat="server" />
</form>
</body>
</html>

Thanks in advance

Number one: The asp button has a field called text. This is what sets the text that appears on the button. This value has to be set for the text to display.

Number two: you have onserverclick as your click command. This should just be onclick="Click".

Hope this helps


When you tell your button, onServerClick="Click" your telling it, to execute a sub or function called "Click" which doesnt exist in your example.

To get the text of your button to show up, do this.

<asp:ButtonText="MyButton"runat="server"ID="Button1"/>


Msamford and Freakyuno,

Thanks a lot for your response. I tried playing with the code.

As requested by you, when I try any one of the following within the aspx code the display works fine and when I click on the "Confirm" button I see "Done" at the bottom of the screen.

<asp:button id="mybutton" Text="Confirm" OnServerClick="Click" runat="server"/>

<asp:Button Text="Confirm" runat="server" ID="Button1" />

However, when I use the following line of code, I see that the output is exactly the same but when I click on the "Confirm" button, I see an "Error on Page" at the bottom of the screen instead of "Done". I tried the following Code Behind for the event handler.

<p><button id="mybutton" OnClick="Click" runat="server">Confirm</button></p>

CodeBehind

<script runat="server" language="C#>
void Click(Object s, EventArgs e){
Response.Write(mybutton.ID);
}
</script>

Code Behind

//First off we import some useful namespaces
using System;
using System.Web.UI;
using System.Web.UI.WebControls;

//All code-behind classes generally inherit from Page
public class SimpleForm3 : Page
{
// Declare the presentation elements on the ASPX page
protected Button mybutton;

//Here's the Click Handler just as it appeared before
public void Click(Object s, EventArgs e){

}
}

I am not sure why. Thanks in advance!!!


Hello,

I added the C# code inside a server-side script block within the header tag of the aspx page. Also, s I am trying to grasp html controls and web forms, I believe the OnServerClick specifies the asp dot net handler for clicks on the button for html controls?

SimpleForm.aspx

<html>
<head>
<script runat="server" language="C#">
void Click(Object s, EventArgs e){
Response.Write("Your name is: " + txtName.Value + "<br />");
Response.Write("Your e-mail is: " + txtEmail.Value + "<br />");
Response.Write("You like to work with: " + servermodel.Value + "<br />");
Response.Write("You like NET: " + likedotnet.Value);
}
</script>
</head>
<body>
<form runat="server">
<h2>Take the Survey!</h2>
<p>Name:<br />
<input type="text" id="txtName" runat="server" /></p>
<p>Email:<br />
<input type="text" id="txtEmail" runat="server" /></p>
<p>Which server technologies do you use?<br />
<select id="servermodel" runat="server" multiple="true">
<option>ASP.NET</option>
<option>JSP</option>
<option>PHP</option>
<option>CGI</option>
<option>ColdFusion</option>
</select></p>
<p>Do you like .NET so far?<br />
<select id="likedotnet" runat="server">
<option selected>Yes</option>
<option>No</option>
</select></p>
<p><button id="mybutton" OnServerClick="Click" runat="server">Confirm</button></p>
</form>
</body>
</html>

Thanks

dotnetnew123


dotnetnew123 wrote:

However, when I use the following line of code, I see that the output is exactly the same but when I click on the "Confirm" button, I see an "Error on Page" at the bottom of the screen instead of "Done". I tried the following Code Behind for the event handler.

<p><button id="mybutton" OnClick="Click" runat="server">Confirm</button></p>

the problem here is you have no asp: in your tag. Therefore when you click the button it is not accessing your servercode. The only way to access the click event is to have the servercontrol properly written with <asp:button ...></asp:button>


Other folks have given you the answer on this, but I'll try since you don't seem to be doing what they advise. Some of my advice might be moot since it could be just a cutting and pasting error, but here we go:

You don't have the @.Page declaration at the top of your document (above even the <html> tag). I just tried your code as-is but with the added page tag and it works just fine.


Thanks all. It works fine now!

Tuesday, March 13, 2012

textbox - radiobutton - button and or sql help

i have 3 textboxes: textbox1, textbox2, and textbox3 and i also have 3 radiobuttons: radiobutton1, radiobutton2, and radiobutton3 and i also have 1 button. the radiobuttons are grouped together to help select one of the three textboxs and the button then when clicked either enables the textbox or disables the other two textboxes all of that seems to work fine except when use textbox1 it reads the sql select statement fine, but when i hit the radiobutton2 or 3 and click the button and then enter a string into either of those textboxes the sql statement does not get read and the formview and gridview are not shown on the screen. i do not know if my problem is in the sql statement or if there is some code i need to ad to the textboxes or radiobutton or button command if you need more information i can send. i am a beginner at this. i need help as soon as possible.Big Smile

Hi,

IMO, it's database connection problem. My suggestion is to usesqldatasource to check it out.

If there is still any problem, please tell us more, especially code.

Thanks.

TextBox and Button

Hey guys...
In my aspx page I have a textbox that when the user press Return I need to
click a button. How can I do it?
OR
All the pages that contains buttons have a default button, but I don't know
how to define the default button. If I do it, my problem will be solved.
Thank'shttp://www.dotnetspider.com/Technol...px?SampleId=212
"Andr Almeida Maldonado" <deweb@.bol.com.br> wrote in message
news:u9d7HtyUEHA.2692@.TK2MSFTNGP09.phx.gbl...
> Hey guys...
> In my aspx page I have a textbox that when the user press Return I need to
> click a button. How can I do it?
> OR
> All the pages that contains buttons have a default button, but I don't
> know
> how to define the default button. If I do it, my problem will be solved.
>
> Thank's
>
Hy Ken
I make this:
<asp:textbox id="txtEntrPrCB" onKeyDown="KeyDownHandler('btnEntrPrMa')"
.....
But when I press Enter, I receive this error:
Object doesn't suport this property or method.
WHY'? What I'm doing wrong?
Thank's
"Ken Cox [Microsoft MVP]" <BANSPAMken_cox@.sympatico.ca> escreveu na mens
agem
news:OFjqo8yUEHA.2668@.TK2MSFTNGP10.phx.gbl...
> http://www.dotnetspider.com/Technol...px?SampleId=212
> "Andr Almeida Maldonado" <deweb@.bol.com.br> wrote in message
> news:u9d7HtyUEHA.2692@.TK2MSFTNGP09.phx.gbl...
to
>
There may be some errant spaces in the code.
How about this?
Ken
<!-->
<%@. Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language="javascript">
function KeyDownHandler(btn)
{
// process only the Enter key
if (event.keyCode == 13)
{
// cancel the default submit
event.returnValue=false;
event.cancel = true;
// submit the form by programmatically clicking the specified
button
alert('Clicked');
btn.click();
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button Runat="server" ID="DefButton" />
<asp:TextBox Runat="server" ID="FirstName"
onKeyDown="KeyDownHandler(DefButton)" />
</div>
</form>
</body>
</html>
<!-->
"Andr Almeida Maldonado" <deweb@.bol.com.br> wrote in message
news:OWahAJzUEHA.2716@.tk2msftngp13.phx.gbl...
> Hy Ken
> I make this:
> <asp:textbox id="txtEntrPrCB" onKeyDown="KeyDownHandler('btnEntrPrMa')"
> .....
> But when I press Enter, I receive this error:
> Object doesn't suport this property or method.
>
> WHY'? What I'm doing wrong?
>
> Thank's
>
> "Ken Cox [Microsoft MVP]" <BANSPAMken_cox@.sympatico.ca> escreveu na
> mensagem
> news:OFjqo8yUEHA.2668@.TK2MSFTNGP10.phx.gbl...
> to
>
Andre,
The code Ken gave you will work, but event.KeyCode will only work for IE and
not netscape. If you want to, I have a bunch of useful javascripts all
rolled into a single component on my website, www.aboutfortunate.com. Click
the code library link on the top right of the page and then click the
javascript button in the menu on the left.
All code on my site is free and the full .NET v1.1 project is downloadable.
So even if you don't want to use the object as is you can get some decent
code examples from it.
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"Andr Almeida Maldonado" <deweb@.bol.com.br> wrote in message
news:OWahAJzUEHA.2716@.tk2msftngp13.phx.gbl...
> Hy Ken
> I make this:
> <asp:textbox id="txtEntrPrCB" onKeyDown="KeyDownHandler('btnEntrPrMa')"
> .....
> But when I press Enter, I receive this error:
> Object doesn't suport this property or method.
>
> WHY'? What I'm doing wrong?
>
> Thank's
>
> "Ken Cox [Microsoft MVP]" <BANSPAMken_cox@.sympatico.ca> escreveu na
mensagem
> news:OFjqo8yUEHA.2668@.TK2MSFTNGP10.phx.gbl...
need
> to
solved.
>
hy
here is some code snippet:
--
put next code in Page_Load
TextBox1.Attributes.Add("onkeypress",
"if(event.keyCode==65)Form1.Button1.onclick();")
when you press 'A' in TextBox,preseding code excute
You can intercept the client side enter keypress event of the text box and
then do what you want using javascript code.
Here's a good example:
http://www.kamp-hansen.dk/pages/sho...id=21&menuid=18
You could also try using this free control.
http://www.metabuilders.com/tools/DefaultButtons.aspx
And here's a couple good articles on the subject:
http://www.allasp.net/enterkey.aspx
http://www.aspnetpro.com/features/2...p200406so_f.asp
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Andr Almeida Maldonado" <deweb@.bol.com.br> wrote in message
news:u9d7HtyUEHA.2692@.TK2MSFTNGP09.phx.gbl...
> Hey guys...
> In my aspx page I have a textbox that when the user press Return I need to
> click a button. How can I do it?
> OR
> All the pages that contains buttons have a default button, but I don't
know
> how to define the default button. If I do it, my problem will be solved.
>
> Thank's
>

TextBox and Button

Hey guys...

In my aspx page I have a textbox that when the user press Return I need to
click a button. How can I do it?

OR

All the pages that contains buttons have a default button, but I don't know
how to define the default button. If I do it, my problem will be solved.

Thank'shttp://www.dotnetspider.com/Technol...px?SampleId=212

"Andr Almeida Maldonado" <deweb@.bol.com.br> wrote in message
news:u9d7HtyUEHA.2692@.TK2MSFTNGP09.phx.gbl...
> Hey guys...
> In my aspx page I have a textbox that when the user press Return I need to
> click a button. How can I do it?
> OR
> All the pages that contains buttons have a default button, but I don't
> know
> how to define the default button. If I do it, my problem will be solved.
>
> Thank's
Hy Ken

I make this:

<asp:textbox id="txtEntrPrCB" onKeyDown="KeyDownHandler('btnEntrPrMa')"
......

But when I press Enter, I receive this error:

Object doesn't suport this property or method.

WHY??? What I'm doing wrong?

Thank's

"Ken Cox [Microsoft MVP]" <BANSPAMken_cox@.sympatico.ca> escreveu na mensagem
news:OFjqo8yUEHA.2668@.TK2MSFTNGP10.phx.gbl...
> http://www.dotnetspider.com/Technol...px?SampleId=212
> "Andr Almeida Maldonado" <deweb@.bol.com.br> wrote in message
> news:u9d7HtyUEHA.2692@.TK2MSFTNGP09.phx.gbl...
> > Hey guys...
> > In my aspx page I have a textbox that when the user press Return I need
to
> > click a button. How can I do it?
> > OR
> > All the pages that contains buttons have a default button, but I don't
> > know
> > how to define the default button. If I do it, my problem will be solved.
> > Thank's
There may be some errant spaces in the code.

How about this?

Ken

<!--->
<%@. Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language="javascript">
function KeyDownHandler(btn)
{
// process only the Enter key
if (event.keyCode == 13)
{
// cancel the default submit
event.returnValue=false;
event.cancel = true;
// submit the form by programmatically clicking the specified
button
alert('Clicked');
btn.click();
}
}
</script
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button Runat="server" ID="DefButton" />
<asp:TextBox Runat="server" ID="FirstName"
onKeyDown="KeyDownHandler(DefButton)" />
</div>
</form>
</body>
</html>
<!---
"Andr Almeida Maldonado" <deweb@.bol.com.br> wrote in message
news:OWahAJzUEHA.2716@.tk2msftngp13.phx.gbl...
> Hy Ken
> I make this:
> <asp:textbox id="txtEntrPrCB" onKeyDown="KeyDownHandler('btnEntrPrMa')"
> .....
> But when I press Enter, I receive this error:
> Object doesn't suport this property or method.
>
> WHY??? What I'm doing wrong?
>
> Thank's
>
> "Ken Cox [Microsoft MVP]" <BANSPAMken_cox@.sympatico.ca> escreveu na
> mensagem
> news:OFjqo8yUEHA.2668@.TK2MSFTNGP10.phx.gbl...
>> http://www.dotnetspider.com/Technol...px?SampleId=212
>>
>> "Andr Almeida Maldonado" <deweb@.bol.com.br> wrote in message
>> news:u9d7HtyUEHA.2692@.TK2MSFTNGP09.phx.gbl...
>> > Hey guys...
>>> > In my aspx page I have a textbox that when the user press Return I need
> to
>> > click a button. How can I do it?
>>> > OR
>>> > All the pages that contains buttons have a default button, but I don't
>> > know
>> > how to define the default button. If I do it, my problem will be
>> > solved.
>>>> > Thank's
>>>>
Andre,

The code Ken gave you will work, but event.KeyCode will only work for IE and
not netscape. If you want to, I have a bunch of useful javascripts all
rolled into a single component on my website, www.aboutfortunate.com. Click
the code library link on the top right of the page and then click the
javascript button in the menu on the left.

All code on my site is free and the full .NET v1.1 project is downloadable.
So even if you don't want to use the object as is you can get some decent
code examples from it.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Andr Almeida Maldonado" <deweb@.bol.com.br> wrote in message
news:OWahAJzUEHA.2716@.tk2msftngp13.phx.gbl...
> Hy Ken
> I make this:
> <asp:textbox id="txtEntrPrCB" onKeyDown="KeyDownHandler('btnEntrPrMa')"
> .....
> But when I press Enter, I receive this error:
> Object doesn't suport this property or method.
>
> WHY??? What I'm doing wrong?
>
> Thank's
>
> "Ken Cox [Microsoft MVP]" <BANSPAMken_cox@.sympatico.ca> escreveu na
mensagem
> news:OFjqo8yUEHA.2668@.TK2MSFTNGP10.phx.gbl...
> > http://www.dotnetspider.com/Technol...px?SampleId=212
> > "Andr Almeida Maldonado" <deweb@.bol.com.br> wrote in message
> > news:u9d7HtyUEHA.2692@.TK2MSFTNGP09.phx.gbl...
> > > Hey guys...
> > > > In my aspx page I have a textbox that when the user press Return I
need
> to
> > > click a button. How can I do it?
> > > > OR
> > > > All the pages that contains buttons have a default button, but I don't
> > > know
> > > how to define the default button. If I do it, my problem will be
solved.
> > > > > Thank's
> >
hy
here is some code snippet:
-----------
put next code in Page_Load
TextBox1.Attributes.Add("onkeypress",
"if(event.keyCode==65)Form1.Button1.onclick();")
when you press 'A' in TextBox,preseding code excute
You can intercept the client side enter keypress event of the text box and
then do what you want using javascript code.
Here's a good example:
http://www.kamp-hansen.dk/pages/sho...id=21&menuid=18

You could also try using this free control.
http://www.metabuilders.com/tools/DefaultButtons.aspx

And here's a couple good articles on the subject:
http://www.allasp.net/enterkey.aspx
http://www.aspnetpro.com/features/2...p200406so_f.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

"Andr Almeida Maldonado" <deweb@.bol.com.br> wrote in message
news:u9d7HtyUEHA.2692@.TK2MSFTNGP09.phx.gbl...
> Hey guys...
> In my aspx page I have a textbox that when the user press Return I need to
> click a button. How can I do it?
> OR
> All the pages that contains buttons have a default button, but I don't
know
> how to define the default button. If I do it, my problem will be solved.
>
> Thank's

Textbox and Button Controls Question

I have a simple web form with a textbox and a button and further down
another textbox and button. My problem is even though I have my cursor
placed in the second textbox, the first button is active. No matter what
textbox I place the cursor in the first button on the page is active.
Is there a function that I should be using to prevent this from happening?
Any help is appreciated. I am in the process of learning ASP.NET.
RtYou could use this free control to solve the problem.
http://www.metabuilders.com/tools/DefaultButtons.aspx
And here are a couple good articles on the subject:
http://www.allasp.net/enterkey.aspx
http://www.aspnetpro.com/features/2...p200406so_f.asp
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"R Tipton" <rrtipton12@.yahoo.com> wrote in message
news:EiA3g.31650$ZB1.4245@.tornado.texas.rr.com...
>I have a simple web form with a textbox and a button and further down
>another textbox and button. My problem is even though I have my cursor
>placed in the second textbox, the first button is active. No matter what
>textbox I place the cursor in the first button on the page is active.
> Is there a function that I should be using to prevent this from happening?
> Any help is appreciated. I am in the process of learning ASP.NET.
> Rt
>
Thank you. I will check them out. -Rt
"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
news:OIhDjrNaGHA.608@.TK2MSFTNGP02.phx.gbl...
> You could use this free control to solve the problem.
> http://www.metabuilders.com/tools/DefaultButtons.aspx
> And here are a couple good articles on the subject:
> http://www.allasp.net/enterkey.aspx
> http://www.aspnetpro.com/features/2...p200406so_f.asp
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://Steve.Orr.net
>
> "R Tipton" <rrtipton12@.yahoo.com> wrote in message
> news:EiA3g.31650$ZB1.4245@.tornado.texas.rr.com...
>

Textbox and Button Controls Question

I have a simple web form with a textbox and a button and further down
another textbox and button. My problem is even though I have my cursor
placed in the second textbox, the first button is active. No matter what
textbox I place the cursor in the first button on the page is active.

Is there a function that I should be using to prevent this from happening?
Any help is appreciated. I am in the process of learning ASP.NET.

RtYou could use this free control to solve the problem.
http://www.metabuilders.com/tools/DefaultButtons.aspx

And here are a couple good articles on the subject:
http://www.allasp.net/enterkey.aspx
http://www.aspnetpro.com/features/2...p200406so_f.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

"R Tipton" <rrtipton12@.yahoo.com> wrote in message
news:EiA3g.31650$ZB1.4245@.tornado.texas.rr.com...
>I have a simple web form with a textbox and a button and further down
>another textbox and button. My problem is even though I have my cursor
>placed in the second textbox, the first button is active. No matter what
>textbox I place the cursor in the first button on the page is active.
> Is there a function that I should be using to prevent this from happening?
> Any help is appreciated. I am in the process of learning ASP.NET.
> Rt
Thank you. I will check them out. -Rt

"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
news:OIhDjrNaGHA.608@.TK2MSFTNGP02.phx.gbl...
> You could use this free control to solve the problem.
> http://www.metabuilders.com/tools/DefaultButtons.aspx
> And here are a couple good articles on the subject:
> http://www.allasp.net/enterkey.aspx
> http://www.aspnetpro.com/features/2...p200406so_f.asp
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://Steve.Orr.net
>
> "R Tipton" <rrtipton12@.yahoo.com> wrote in message
> news:EiA3g.31650$ZB1.4245@.tornado.texas.rr.com...
>>I have a simple web form with a textbox and a button and further down
>>another textbox and button. My problem is even though I have my cursor
>>placed in the second textbox, the first button is active. No matter what
>>textbox I place the cursor in the first button on the page is active.
>>
>> Is there a function that I should be using to prevent this from
>> happening? Any help is appreciated. I am in the process of learning
>> ASP.NET.
>>
>> Rt
>>

Textbox and its corresponding submit button.

I noticed that if I hit enter in the text box instead of clicking on the submit button that the page just refreshes and bttn_click event doesn't occur for the submittal.

After a search I found the following to work:

ClientScript.RegisterHiddenField(string hiddenFieldName, string hiddenFieldInitialValue)

From what I gather this allows the page to have a default button event occur whenever the enter key is pressed in a text box.

My question is how would you go about setting this up for more than one text box and submit button on a page that will do different things other than the default.

I found this:
this.userTxtBx.Attributes.Add("onkeypress", "setEnterKey('userBttn')");
but it does not work in my attempts.

Thanks in advance.After contemplating the problem further, I realize the problem is not so complex.
The simplest solution is html form code defaultbutton=""
Another way is to have a hidden textbox field in your form.

Read this too
http://aspnet.4guysfromrolla.com/articles/060805-1.aspx
Thank you for this.

TextBox and ImageButton

Hello,

I added a TextBox and an Image Button to a page so that they are side by side.
Instead of both being top aligned the Text Box is pushed down.

Why is that?
How can I solve this?

Thanks,
Miguel

Insert a table of 1 row, 2 columns (I do it from the Layout menu)

Put the TextBox in one cell, the Image Button in the other.

You may have to play with the cell alignments to get it to look the way you want.


Tables are the easiest way to handle controlling the layout of your page. If you're not going to use css to control your layout, you'll need to use tables. Good Luck!

Hi,

I don't use tables. I always use CSS for layouts.

Anyway, I was able to solve it. Just set my ImageButton's ImageAlign property to Top and everything went fine.

Thanks,

Miguel


Great, css is far better for your work. Good Luck

shapper:

Hi,

I don't use tables. I always use CSS for layouts.

Anyway, I was able to solve it. Just set my ImageButton's ImageAlign property to Top and everything went fine.

Thanks,

Miguel

I just recently learned an even easier way to control your layout. Go to the layout tab, then go to position > auto-position options > then check the checkbox for changing position for controls added.

That should really spice things up for ya, good luck!

TextBox and popup Grid (other .aspx)

In .aspx page I have ASP.NET
1TextBox(txtFirst) 1 Button (btnSearch)
1 TextboxtxtLast) and a MS SQL DB (Table with the fields First Name, and Last Name)
What I want it is:
- I want to enter some text in first TextBox
-After I clicked btnSearch to jump in other .aspx with a Data Grid
-After I browse what I want, I will choose a Last Name.
-After Selection I want to put the data from the Grid in both TextBoxes
Please! Thanks.I'm on chapter 5 of the book you have just requested but in the meantime I recommend you pay 4guys a visit and read some of the excellent tutorials on asp.net, in particular the stuff on datagrids and other server controls - http://www.4guysfromrolla.com - what you want to do is quite involved and would take some time to explain what is already well documented on the net.