0

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" from 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"/>

3
Contributors
2
Replies
12
Views
4 Years
Discussion Span
Last Post by JorgeM
0

With runat server the id of the inputbox is changed, so your function doesn't find it.

Try adding the attribute ClientIDMode="Static"

Edited by pritaeas

0

The runat makes the asp or html elements accessible for you to manipluate via asp.net. It would be easier to see your code as a whole, but just curious as to why you are mixing asp.net server, web controls and HTML elements together?

For example, why use one html element for a button, then use a web control for another button and another input element as a server control.

What about the showPoint() javascript function?

Edited by JorgeM

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.