Really Stuck on a Canlendar Control PLEASE HELP!!!

M

Midway

Hi guys,

This is what I'm doing, have a calendar control that I'm invoking from an
hyperlink. the calendar control has some javascript code that when I pick a
date, the date gets transffered to a text control on the calling form, that
is all work working fine.

Now here's the chanllenge that I'm just really stuck. I want to get that
date from the calendar control to a text box within a Detailsview control. I
have been trying so many things but nothing seems to work.

Please some ideas on how I can do this PLEASEEEE.

Thanks so much.

Manny
 
M

Midway

The Hyperlink that is invoking the Calendar control is;
javascript:calendar_window=window.open('calendar.aspx?formname=NewEmployeeform.TextBox4','calendar_window', 'width=350,height=290');calendar_window.focus()

The TextBox4 is a control outside the detailsview. what I was trying was to
get that date to this TextBox4 control and pass that date to the TextBox
within the Detailsview, I was able to do that but I need a post back to the
server so the date shows up in the TextBox control within the Detailsview,
but in order to get a post back to the server I need to clink on a button,
that is not gonna work on the user interface.

User should be able to just to click on that date and date should be
inserted with the Date field in the details view no more actions done.


Thanks for your help.

Manny
 
O

offwhite

I have posted an example here...

http://brennan.offwhite.net/jsparent/

That will open a child window which allows you to set a value in a
textbox and then send that back to the parent. In your situation you
need a place in the parent where you can set that value. If you have a
hidden field (input of type hidden) you can target it if you know the
ID. And if you are using an ASP.NET control you will need to figure
out that ID since the ClientID is what is actually used in the HTML.

You could just shorten the ClientID.

http://blog.danbartels.com/archive/2005/11/11/1110.aspx

What I have done to always know the value of the ClientID is to call
RegisterScriptBlock with Javascript created to set to the value of the
ClientID which can then be used in a static Javascript function.

In my example you can use much of the code without making changes. The
Javascript/DOM code should look very similar for your solution.

Brennan Stehling
http://brennan.offwhite.net/blog/
 
M

Midway

Hey Thanks very much for your reply. if it's not too much to ask, how would
translate this code into VB? sorry I'm not that good with C#, I'm learning
though, but if you could do this would be ownsome.

Thanks very much.
 
M

Midway

Sorry about the last post about the VB code. What I ws trying to ask is; how
do I find out the ID of the textbox that I want the value to come down from
the child?
 
O

offwhite

Download Lutz Roeder's Reflector. It is a .NET utility which allows you
to load .NET assemblies and browse them. When you double-click on a
class or method it can actually show you the code. You can display the
code as any .NET supported language. Then you can take that C# code,
compile it, load the assembly and view it as VB.NET. :)

I do both VB.NET and C#, but sometimes I come across some syntax I am
not sure how to translate so I use this technique.

To get the ID value for the Javascript, I place this in my web page as
static Javascript.

<script type="text/javascript">

var controlClientId;

function setControlClientId(newId) {
controlClientId = newId;
}

// use controlClientId in your Javascript

</script>

Then build your string for Javascript in the code-behind and add it to
the page.

Dim scriptString as String = "<script type='text/javascript'>" + vbCrLf
+ _
" setControlClientId(" + control.ClientID + ");" + vbCrLf + _
"</script>" + vbCrLf

I am not looking at working code as I write this so my syntax may be
off and you may want to use a different property than ClientID but I
think that is correct.

To add Javascript to the page from a code-behind class, use the
RegisterClientScriptBlock method. It has been updated in ASP.NET 2.0.

ASP.NET 2.0
http://msdn.microsoft.com/library/d...UIPageClassRegisterClientScriptBlockTopic.asp

ASP.NET 1.1
http://msdn.microsoft.com/library/d...UIPageClassRegisterClientScriptBlockTopic.asp

Those pages should have some decent code for you to follow.

Brennan Stehling
http://brennan.offwhite.net/blog/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top