3 Replies - 1482 Views - Last Post: 29 August 2013 - 06:34 PM Rate Topic: -----

#1 Black_Lion  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 31-March 13

Textbox not working when adding runat="server"

Posted 29 August 2013 - 10:46 AM

I am using Microsoft Visual Web developer 2010. I have Google Maps embedded on my webpage and a textbox (txtBoxInput) using the code:

<input runat="server" type="text" id="txtBoxInput"/>

A button which displays a new map loction:

<input type="button" id="btnDisplay" value="Display map" style="height:34px;width:90px;" onclick="showPoint();"/>

I also have an aspn.net button (btnTest) using the code:

<asp:Button ID="btnTest" runat="server" onclick="Button1_Click" Text="Button"/>

And the code in btnTest's event:

    protected void Button1_Click(object sender, EventArgs e)
    {
        string test = txtBoxInput.Value = "New York, United States";
    }

When I click the button (btnTest), the textbox (txtBoxInput) gets filled with "New York, United States". I then click btnDisplay but nothing happens.

When I remove runat="server" so that code is:

<input type="text" id="txtBoxInput"/>

It works. When it is removed txtBoxInput isnt recognised in the asp.net btnTest event.

Is there a way to fix this? The cause must be because of the line: <input runat="server" type="text" id="txtBoxInput"/>

This post has been edited by andrewsw: 29 August 2013 - 11:10 AM
Reason for edit:: Removed whitespace


Is This A Good Question/Topic? 0
  • +

Replies To: Textbox not working when adding runat="server"

#2 laytonsdad  Icon User is online

  • Cheese and Sprinkles
  • member icon

Reputation: 409
  • View blog
  • Posts: 1,729
  • Joined: 30-April 10

Re: Textbox not working when adding runat="server"

Posted 29 August 2013 - 11:07 AM

Asp.net controls are for server-side control, if you wnat to use javascript you will need to use HTML.

Try using an HTML <button></button> instead of an asp.net control.


I miss read your question.

This post has been edited by laytonsdad: 29 August 2013 - 11:17 AM

Was This Post Helpful? 0
  • +
  • -

#3 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 2890
  • View blog
  • Posts: 9,597
  • Joined: 12-December 12

Re: Textbox not working when adding runat="server"

Posted 29 August 2013 - 11:12 AM

Moved to ASP.NET, slightly more relevant than just Javascript.
Was This Post Helpful? 0
  • +
  • -

#4 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 441
  • View blog
  • Posts: 1,488
  • Joined: 28-April 09

Re: Textbox not working when adding runat="server"

Posted 29 August 2013 - 06:34 PM

Is there a reason you are trying to use an html text input element instead of an asp.net TextBox control?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1