• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 696
  • Last Modified:

TextBox Causing A Postback In Dynamic .ascx Control

I have a ascx control that contains an asp:Textbox control. I add the ascx control to a web form dynamically. If I click inside this textbox (that is read only and autopostback is false) and then click a key on the keyboard it causes a postback. If the textbox is in a web form and now anscx control obviously it does not cause a postback and everything works correctly. Is there a way to stop this postback from happening? What about using html textboxes instead will that fix it? I need the textbox to do 2 things:

1. Populate with data from the db on the loading of the control (uncertain if this is even possible with an html textbox)
2. Get access to the textbox through code if not in read only mode. Ive tried to access an html textbox in code behind and I am unsure how. The Id of an html textbox is not accessible from code behind.
0
npl77
Asked:
npl77
  • 2
  • 2
1 Solution
 
Bob LearnedCommented:
The TextBox control shouldn't cause a post-back in that configuration, so I believe that there is another explanation.  You shouldn't have to change to <input> elements.
0
 
npl77Author Commented:
You know what your right because when I do this on a test page no postback occurs. Let me look more into it and try to figure out why this is happening....
0
 
npl77Author Commented:
Whats happening is when I click the "Backspace" key after giving one of these textboxes focus. The code is automatically going back to the previous ascx control that was loded into the placeholder. Does that make any type sense?
0
 
Bob LearnedCommented:
No, that is not a normal problem.  You are going to have to show me something that would attempt to explain the problem in more detail...
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now