Text box - Text changed event

I have a Popup calendar that opens when i click on the parent form and, and after selecting date - it fills the parent textbox and closes the popup window.

Every thing is working fine, but i have one problem, i want the Textbox - textchanged event to fire when there is a change,(auto postback for textbox is set to true).
This is not happening. If i manually type in the date in the textbox and go to other control then it fires, but not when i select date from PopUp.
How to make it work
Appreciate any response.
Thanks.

Parent Form
JAVASCRIPT
function OpenCalendar(obj1) {
var w=window.open("../PopupCalendar.aspx?textbox="+obj1+",,width=625,height=760,scrollbars=yes,resizeable=yes");

CODE BEHIND
txtText = New WebControls.TextBox
txtText.ID = "txtDate" & j
txtText.AutoPostBack = True
AddHandler txtText.TextChanged, AddressOf TextBox_TextChanged

hypLink = New HyperLink
hypLink.ID = "hypCal" & j
hypLink.ImageUrl = "../images/SmallCalendar.gif"
strJS = "javascript:OpenCalendar('txtDate" & j & "');"
strJS = "window.open('../PopupCalendar.aspx?textbox=txtDate" & j & "','cal','width=250,height=225,left=270,top=180')"
hypLink.Attributes.Add("onClick", strJS)
hypLink.NavigateUrl = "javascript:;"

POPUPCALENDAR.ASPX
CODE BEHIND
Protected Sub Change_Date(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim strScript As String = "<script>window.opener.document.forms(0)." + control.Value + ".value = '"
strScript += calDate.SelectedDate.ToString("MM/dd/yyyy")
strScript += "';window.close()"
strScript += "</" + "script>"
RegisterClientScriptBlock("anything", strScript)
End Sub

-1
nkunapaneni
11/5/2004 3:04:45 PM
asp.net.web-forms 93655 articles. 5 followers. Follow

3 Replies
1306 Views

Similar Articles

[PageSpeed] 9

By design, the browsers only fire their onchange event when the user explicitly edits the textbox and the field loses focus. When you programmatically change the value of the textbox, onchange will not fire.

The AutoPostBack feature generates its javascript in the onchange event.
Your goal is to run the __doPostBack() function that is on the original window. I'm not sure how to do that from the second window.
FYI: DateTextBoxes are the most common control available on ASP.NET. Third parties have created so many of them, some free, some fancy with a price. The better ones popup their calendar using the same window. This requires they replace the Microsoft calendar with one that uses javascript to update itself without posting back on each click. The benefits are several:
- The separate window can easily get hidden behind the original one.
- No more posting back, which improves user interaction and reduces server time used
- They position perfectly near the popup button
- Its easy for the third party control to call that __doPostBack() function since is on the same page.
You can learn about the many DateTextBox controls at these sites: www.asp.net's Control Gallery, www.123aspx.com, and 411asp.net.
I make the one called Peter's Date Package. It has the advanced calendar features I've described (no post back, no separate window). It supports auto post back when you change an item on the calendar.

--- Peter Blum
Creator of Peter's Data Entry Suite (formerly Professional Validation And More and Peter's Date Package) and Peter's Polling Package
www.PeterBlum.com
0
PLBlum
11/5/2004 4:55:02 PM
Thanks for the reply. 

But is there a way to do this without using third party controls?
Thanks.
0
nkunapaneni
11/5/2004 5:48:34 PM
I had a work around for this - by 

using ImageButton that will postback instead of HyperLink AND
Making the Calendar as ModalDialog.
I have the Code here - in case if some one is looking for same kind of solution.
PARENT FORM
***** JAVASCRIPT *********
function OpenCalendar(obj1) {
strVal = document.getElementById(obj1).value;
strFeatures = "dialogWidth=265px;dialogHeight=235px;scrollbars=no;center=yes;border=thin;help=no;status=no";
strURL = "../PopupCalendar.aspx?textbox=" + obj1
retval=window.showModalDialog(strURL,"",strFeatures);
if (retval==null) {
return false;
}
if ((retval.length > 0) && (retval != "")) {
document.getElementById(obj1).value = retval;
strVal1 = document.getElementById(obj1).value;
if (strVal != ""){
if (strVal == strVal1) {
return false;
}else {
return true;
}
}
else {
return true;
}
}
}
***** CODE BEHIND *********
txtText = New WebControls.TextBox
txtText.ID = "txtDate" & j
txtText.AutoPostBack = True
txtText.EnableViewState = True
txtText.Width = Unit.Pixel(90)
AddHandler txtText.TextChanged, AddressOf TextBox_TextChanged
c.Controls.Add(txtText)
imgButton = New ImageButton
imgButton.ID = "imgCal" & j
imgButton.AlternateText = "Calendar"
imgButton.ImageUrl = "../images/SmallCalendar.gif"
strJS = "javascript:return OpenCalendar('txtDate" & j & "');"
imgButton.Attributes.Add("onClick", strJS)
c.Controls.Add(imgButton)

POPUP CALENDAR
***** JAVASCRIPT*********
function fGetCalDate(strCalDate){
window.returnValue = strCalDate;
window.close();
}
***** CODE BEHIND *********
Protected Sub Change_Date(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim strScript As String
strScript = "<script>fGetCalDate('"
strScript += calDate.SelectedDate.ToString("MM/dd/yyyy")
strScript += "');"
strScript += "</" + "script>"
RegisterClientScriptBlock("anything", strScript)
End Sub
0
nkunapaneni
11/15/2004 7:50:17 PM
Reply:

Similar Artilces:

How to fire events in other web form from other web form ?
Suppose that I have A and B web form. I want to trigger B web form's Page_Load event from A web form. How can I do that ? Thanks in advanced WilbertWilbert Bujn Create a public method in B that call the load method : public void Load(object sender, System.EventArgs e) { Page_Load(sender, e) ; } In the page_load of A, instanciate a B object and then call the function B myB = new B() ; myB.Load() ; Quicky Thank you quicky, it works fine. WilbertWilbert Bujn...

superreview granted: [Bug 240285] form change event not properly detected by the popup blocker : [Attachment 145907] detect form change events
Johnny Stenback <jst@mozilla.jstenback.com> has granted Dan M <danm-moz@comcast.net>'s request for superreview: Bug 240285: form change event not properly detected by the popup blocker http://bugzilla.mozilla.org/show_bug.cgi?id=240285 Attachment 145907: detect form change events http://bugzilla.mozilla.org/attachment.cgi?id=145907&action=edit ------- Additional Comments from Johnny Stenback <jst@mozilla.jstenback.com> sr=jst ...

superreview requested: [Bug 240285] form change event not properly detected by the popup blocker : [Attachment 145907] detect form change events
Dan M <danm-moz@comcast.net> has asked Johnny Stenback <jst@mozilla.jstenback.com> for superreview: Bug 240285: form change event not properly detected by the popup blocker http://bugzilla.mozilla.org/show_bug.cgi?id=240285 Attachment 145907: detect form change events http://bugzilla.mozilla.org/attachment.cgi?id=145907&action=edit ...

Implementing .Net Form into an APS.net web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an ASP.net web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

VS.NET 2005 Web Forms Designer Changes
Word on the street is the web forms designer architecture has vastly improved in VS.NET 2005. That's great for me, since I write plenty control designers and add-ins and 2003 has bothered me in more ways that I care to discuss. But I can't find a good place to get the info on the designer changes in 2005. Could someone link me to some resources? Thanks There are a few resources: Check out the quickstarts for beta1. i think we added some very basic details there, but there are also some comments in 477688 686110 for some general details.SimonThis posting is provided "...

How to add event to Web Form from the vs.net designer
 Hi there, I know that when i double click a web form I'm taking to the page_load event.  However, I want to create an unload event by I don't know how to create it from the vs.net designer.  Does anybody know how to create a page unload event from the vs.net designer? Many thanks  Page events are not exposed in the design view. If you are using VB, you should be able to use dropdowns on top of the code editor -> select Page in the left one and the designed event in the right one and editor will generate the code. Unfortunately, C# editor does not p...

using javascript to change .net web form properties
Hello everyone, I'm fairly new to ASP.NET and I'm trying to find the best solution to this problem I'm having.  I believe ultimately what I need to be able to do is change the ImageUrl value via javascript of an ImageButton.  A small example of what I'm working on can be found here in a javascript form:http://www.msu.edu/~sebenic3/This is a simple data input method for a survey. There are three distinct columns, when you select a number within a column it will change the .gif image to show it's selected and then populate the textbox with that value.  I...

change web form background property from code in vb.net
I have a web form in a vb.net project. The web form has both a design view and an HTML view. In the design view, the property box has a background property that can be set to an image file. This causes a background attribute to be added to the Body element in the HTML view. My question is, how do I modify the background property from program code? I can't find the object that has this property so I can set its value. On way to do it is to use 2 different style sheet and change the stylesheet in the pageload event depending on your condition. Look for an example in Report Starter Kit ...

.NET 1.1 Web Form
I am scratching my head trying to figure out why my events button (Lighting Bolt) is not displaying when I select buttons in Visual Studio 2003.  Has anybody had this happen before? I am tired into Visual Source Safe and wonder if that has anything to do with it?Moojjoo Õ¿Õ http://www.mmwebs.comhttp://moojjoo.blogspot.com/ Ummm>>>   That is the difference between C# and VB.NET.  VB.NET does not display the Lightning Bolt under properties in VS 2003.Moojjoo Õ¿Õ http://www.mmwebs.comhttp://moojjoo.blogspot.com/...

add/change name/delete server files via vb.net web form
I have the add(upload) part of this page figured out. I have an application with an "Images" sub directory. I know how to access the getfiles() method from the system.IO namespace. I am using a while loop to create a table with an edit button (so that you can change the name of the file) and a delete button so you can remove the file from the server. Each file is on a new line much like it would look if it was bound to a datalist or datagrid. Here is where I am clueless. Can anyone point me in the right direction? I am not looking for someone to write this for me, beca...

windows forms in vb .net into web forms
we are creating a database driven website as part of our project. currently we have forms connecting to the database created in visual basic. these windows forms we need to convert into web forms which are asp .net compatible. can u give me an answer or show me a way. Hi, because of the difference in nature between web and win applications you'll need to reimplement at least the UI part. If you have a multitiered application in which the busines logic and data access are in different parts/assemblies you can reuse them. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Wor...

Submitting Web forms fields to sql database by clicking on SUBMIT FORM and sending the form fields to email box
I have a created or designed a form to be stored in a SQL database table and at the same time when a user clicks on SUBMIT button the form fields will automatically goto the visitor email address immediately. Also i have created a database with tables for each of this forms Pls help i have over 10 forms designed but the problem of submitting them to the table database and the user email address is the challenge now.... You ned to familiarise yourself with the basics of database access in ASP.NET.  There are free tutuorials here: http://quickstarts.asp.net/QuickStartv20/aspnet/doc/da...

.Net Web Form & Web Service Deployment
Hi all I have written some test web services and some web form applications and deployed them to my IIS. That's fine but I now want to deploy them to my real IIS server. I have created an msi for each but the problem is I seem to only be able to deploy to the default web site. Our default web site is turned off and instead we use several other sites. Does anybody happen to if Powerbuilder 11 supports non default web sites? If not do I need to hack the msi and if so can anybody suggest a suitable tool. I have Orca but it's not very friendly. Unless of course I knew exactly w...

how to change these windows form code to web form code?
hi, i'm a beginner of c#,i want to know how to change these windows form code to web form code //////////// private void buttonSign_Click( object sender, System.EventArgs e) { //get original message as byte array byte[] messagebytes = Encoding.UTF8.GetBytes( textOriginalMessage.Text); //create digest of original message using SHA1 SHA1 sha1 = new SHA1CryptoServiceProvider(); byte[] hashbytes = sha1.ComputeHash(messagebytes); //display hash bytes in hex format StringBuilder sb = new StringBuilder(); for (...

Web forms and mobile web forms
Hey everyone, I am looking to develope a web site that depending on the device connecting to it, it will display a certain page. In this case im looking to create a web and wap version of the same project. I have the Web forms version finished using ASP.NET and C# and I am wondering how to create the mobile web form and incorporate it in the project. In the project folder, can I just add a mobile web??? But what about displaying device specific pages?? Cheers -Dudach Yes, you can add mobile web forms and controls to your Web Application project. No problem. For device/br...

Web resources about - Text box - Text changed event - asp.net.web-forms

The Day the Universe Changed - Wikipedia, the free encyclopedia
The Day the Universe Changed (subtitled "A Personal View by James Burke") is a British documentary television series written and presented by ...

How Has Facebook Changed News Delivery?
... cats — it altered the way stories are seen. Now everyone can make news. But for those who make a living by spreading news, Facebook has changed ...

Facebook changed my name to my unknown birth name, not my current legal name... - Facebook-Hilfeforum ...
I provided Facebook with my original birth certificate and my name change certificate - instead they changed my name to my birth name which I ...


West Wing Changed Me (@WWChangedMe) on Twitter
Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

Changed the AWS instance size on the Trex server from small to large, and now it runs much better. ;-) ...
A bunch of people made suggestions after reading today's Changes piece. The one that made the big difference came from my longtime programming ...

Economics : How has introductory economics changed as it's been taught in American universities over ...
Answer (1 of 5): Introductory economics has not changed enormously over the years. In part this is because much of introductory economics is ...


Knuckle Up #398: UFC 178, Cry Babies, HeadGames + Suddenly Your DNA Is Forever Changed… (MMA Nation) ...
Literary gunslinger Eugene S. Robinson of http://BloodyElbow.com lends his one-of-a-kind perspective on UFC 178 up to and including the TEARS ...

Qld cabinet reshuffle: Whose portfolio has changed
Whose portfolio has changed in the new Queensland government cabinet.

Resources last updated: 12/8/2015 3:55:28 AM