Showing posts with label control. Show all posts
Showing posts with label control. Show all posts

Wednesday, March 28, 2012

calling javascript functions

I am working on an ajax web page which has several controls including a ScriptManager control and the ajax Timer control. When the timer fires a tick I want the server side to perform some calculations and then call a client script function with the results. The client script will then do something with the results.

Also, I want to call another javascript function when I click a button.

I'm a bit rusty with javascript, so I'd like to see examples on how to make this work.

What and where exactly you want to do?

When the timer fires, I want the server to generate (calculate) a pair of integers (or possibly an array of pairs) and call a javascript function on the client side passing those numbers. The client will then "plot" points on a graphics window using some built-in drawing java functions I have. The timer will probably fire several times a second. The client does not need to make any calls to the server.

When a button is clicked, I want the server to call another javascript function (passing no arguments) which will erase the graphics window. The timer continues firing.

I have other buttons, to start and stop the timer, sliders to change the timer rate and other parameters, checkboxes and radio buttons which also affect the calculations, etc. All I need help with is making the client calls and passing the data. Is the ScriptManager useful in that respect? By the way, I'm kind of "new" in java.

I've seen scenarios where client calls server, and server calls the client back with a reply. However, can the server just call the client repeatedly? Or does the timer control act as the client-to-server caller?


Yo can use for calling javascript function

Registering Custom Script

from ScriptManager

http://ajax.asp.net/docs/mref/O_T_System_Web_UI_ScriptManager_RegisterClientScriptBlock.aspx

For calling server side function use web services..


Actually, what I need to do requires "COMET", a form of "reverse AJAX". Is there an easy way to emplement COMET in ASP.Net? When the user clicks the "start" button, the server needs to begin "firing" pairs of numbers at the client at a steady rate (several times a second) until the user clicks the "stop" button.


Hi,

According to theclient life cycle, you can hook an event handler to theloadevent which will be fired every time an partial postback returns. Then invoke your graphical jscript function in it. For instance:

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<script runat="server"
</script
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager
</div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" Interval="1000">
</asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>
<input id="time" />
</form
<script type="text/javascript">
function draw(){
var dt = new Date();
$get("time").value = dt.toString();
}

Sys.Application.add_load(ApplicationLoadHandler)

function ApplicationLoadHandler(sender, args)
{
draw(); // invoke your graphical function instead
}
</script
</body>
</html>


Thanks, but I didnt get it what does this do ?


 <script type="text/javascript">
function draw(){
var dt = new Date();
$get("time").value = dt.toString();
}

Sys.Application.add_load(ApplicationLoadHandler)

function ApplicationLoadHandler(sender, args)
{
draw(); // invoke your graphical function instead
}
</script>


This is a javascript function with no usefulness at all, just for demostration purpose. You need to invoke what you really need here.

I need the server to send a pair of numbers to the client each time it fires.


You can expose the method of sending numbers as a web service on the server.

Then invoke it at client side.

Please read this:

http://ajax.asp.net/docs/tutorials/ConsumingWebServicesWithAJAXTutorial.aspx

Calling javascript from ASP.NET AJAX

I am trying to read a cookie with some javascript, without postback, using a timer control. I all need to do is return the value of the .js file and use it in the timer event.

So far here's what I have done:

I have a ScriptManager and an updatepanel with a timer control inside.

I set the ScriptReference to the file that reads the cookie:

<Scripts>
<asp:ScriptReference Name="ReadCookie" Path="javascripts/ReadCookie.js" />
</Scripts>

The timer calls this event:

protected void Timer1_Tick(object sender, EventArgs e)
{

}

My Question is how do I call that cookie and access the value in my code behind?

Thanks, Justin.

I guess I'll should restate my question:

How do I call a javascript function that has been added to the scripts collection of the scriptmanager (as shown above) from my c# codebehind?

Thanks, Justin.


You can register that JavaScript function in Timer's Tick Event.


Yes, I have tried that with no success but maybe I am doing it wrong:

<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
<Scripts>
<asp:ScriptReference Path="ReadCookie.js"/>
</Scripts>
</asp:ScriptManagerProxy>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" Interval="10000" OnTick="readCookie">
</asp:Timer>

....

readCookie.js:

function readCookie() {
var nameEQ = "PhoneNumber" + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') {
c = c.substring(1,c.length);
}

if (c.indexOf(nameEQ) == 0){
return c.substring(nameEQ.length,c.length);
}
else {
return null;
}
}
}

if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();

I Get this Error:

Compiler Error Message:CS0117: 'ASP.agents_customerdetailsform_aspx' does not contain a definition for 'readCookie'


Hi, Justin


Check this link for answer and more help:

  • CS0117 :: 'Type' does not contain a definition for 'Identifier' :http://dotnetslackers.com/_NET/re-56753_CS0117_Type_does_not_contain_a_definition_for_Identifier.aspx

  • Calling javascript from a control

    I think this is a newbie question but it has me stumped.

    I want to call a javascript function on a control when an event is fired. Specifically I want to call a javascript function when the value of a label changes.

    i.e.

    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

    When that changes, call the javascript function HelloWorld()

    that label is getting updated through a slidercontrol, so I was thinking about using the "onunload" event, but I'm really not sure.

    I don't think the label control has onchange event in javascript. You could implement an AJAX timer and check if the label was change every x amount of second.

    Sample how to use the Ajax timer here:http://alpascual.com/blog/al/archive/2006/12/21/Code-Snip-_2200_AJAX-Timer_2200_.aspx

    Calling Clinet Function from Code Behind (Inside Ajax Update panel)

    Hi,

    Can anyone please provide information on how I can do this:

    I have a GridView control inside an Ajax Update panel and have wired the Selected IndexChanged action to call a Client side Javascript function (ViewReceipt()). Unfortunately it doesn't seem to work except if I take the control outside the update panel.

    Have posted my code below..

    protected void rgvInv_SelectedIndexChanged(object sender, EventArgs e)
    {
    // Now execute the client-side stuff...
    StringBuilder sbScript = new StringBuilder();
    sbScript.Append("\n<script language=\"JavaScript\" type=\"text/javascript\">\n");
    sbScript.Append("<!--\n");
    sbScript.Append("ViewReceipt();\n");
    sbScript.Append("// -->\n");
    sbScript.Append("</script>\n");
    this.RegisterStartupScript("ClientSideCall", sbScript.ToString());
    }

    Regards..

    Peter.

    Hi,

    Found some posts on this and tried to add the recommended code but still getting a syntax error, hope someone can help out..

    code behind:

    protected void rgvInv_SelectedIndexChanged(object sender, EventArgs e)
    {
    // Now execute the client-side stuff...
    StringBuilder sbScript = new StringBuilder();
    sbScript.Append("\n<script language=\"JavaScript\" type=\"text/javascript\">\n");
    sbScript.Append("<!--\n");
    sbScript.Append("EditReceipt();\n");
    sbScript.Append("// -->\n");
    sbScript.Append("</script>\n");
    //this.RegisterStartupScript("ClientSideCall", sbScript.ToString());
    //ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "ClientSideCall", sbScript.ToString(), true);
    ScriptManager.RegisterStartupScript(this, this.GetType(), "ClientSideCall", sbScript.ToString(), true);

    }

    Javascript Function:

    function EditReceipt()
    {
    var manager = GetRadWindowManager();
    var rwEntry = manager.GetWindowByName("rwReceipt");
    }


    Regards..

    Peter.


    Hi Peter,

    The problem with your code is that you should specify the last parameter to false in RegisterStartupScript method.

    This parameter indicates that <script> tag will be added automatically to wrap the sbScript. Since you've done that manually, so false should be used.

    Like this:

    ScriptManager.RegisterStartupScript(this, this.GetType(), "ClientSideCall", sbScript.ToString(), false);

    Hope this helps.


    Hi Peter,

    Give full definition of EditScript() function then only I can help to you.

    Regards,

    Aru


    Raymond,

    Thanks for the information, I have already implemented a work around by moving the grid outside of the update panel. I'm using a telerik grid which has inbuilt AJAX and there are some clientside events which can be hooked into that has given me the functionality I require, anyway thanks for the information I can use it else where later.

    Regards..

    PeterBig Smile

    Calling AJAX function

    Hi, I wonder if there's a way to call an AJAX function via code behind page. That is, I have an asp tab control on my page, in which on pressing a tab I open a menu via AJAX code and ask user to enter password then I validate that password and want to select that tab if password is correct. Since my tab is asp control the AJAX code doesn't know that so I have to return the password to the code behind page but since I have to call such function through AJAX:

    [Ajax.AjaxMethod(HttpSessionStateRequirement.ReadWrite)]
    public void CheckRoomPsw(string psw)
    {

    ...

    }

    I don't have access to Tab control because this returns null, so there's two options which I don't know how to perform:

    1. call an AJAX control from CheckRoomPsw(string psw)

    2. get an access to tab control in CheckRoomPsw(string psw)

    Any idea is appreciated.

    have you tried using the findControl function. it lets you access a conrol by referencing its location and using its ID. so if you had a bunch of controls on your form and wanted to get to one you could do.

    form1.findControl("controlIDgoesHere");

    if yours is inside of some ajax stuff it might be like

    UpdatePanel1.findControl("myControlsID");

    then you can just cast that to reference the object type

    string value = ((TextBox)form1.findControl("txtUserName")).Text;


    Actually, I've done that:

    [Ajax.AjaxMethod(HttpSessionStateRequirement.ReadWrite)]
    public void CheckRoomPsw(string psw)
    {
    JQD.TabStrip ts = (JQD.TabStrip)this.FindControl("TabStrip1");
    ts.SelectTab(Global.tabPos);
    }

    but this returns null!!

    I think it's because CheckRoomPsw() is an AJAX function


    Perform the tab selection on the client-side callback. Return a boolean from the AJAX method after you check the password, if it is true perform the tab selection.


    Also, it looks like you're using AJAX.NET, which is a completely separate product from ASP.NET AJAX, so you might want to see if they have a forum.


    Have you had luck fixing your issue?

    -Damien


    Not yet!

    I'm still looking for solution!


    Have you tried doing the tab selection client-side?


    I tried much to get access to the tab control from js code (client side) but since the tab control is an asp user control, it can't be known from js code.


    Use theOnClientActiveTabChangedproperty on the tab. Seehttp://asp.net/AJAX/Control-Toolkit/Live/Tabs/Tabs.aspx for more information.

    -Damien


    Thanks for your concern Domien!

    However, I'm not using AJAX.net and don't know much about itEmbarrassed and it's a bit risky to change my tab control now that I'm on the final steps of completing my project

    IS there any other solution please

    Calling a web service in a javascript causes page reload

    Hey guys,

    Here is what is happening. I have a user control in which I have an update panel with a button and some label. On click of that button, I call a javascript function which in turn calls a web service. The web service does get called and everything works nicely, but the whole page is being refreshed. The moment the javascript calls a web service, the refresh of the whole page occurs (when in turn nothing should happen besides the web service called).

    Do I have something misconfigured that causes the script manager to do the whole page refresh on a web service call? I have the same structure in another control, and that one doesn't cause the page refresh.

    If anyone has experienced this and have a solution for it, I would love to hear it.

    Thanks!

    Are you using Server Button Control(<asp:Button/>) of usual html button(<input type="button"> ?

    I'm assuming you have something like:

    <asp:Button ... OnClientClick="CallMyWebService()" />

    or

    <input type="button" ... onclick="CallMyWebService()" />

    Try making it "CallMyWebService(); return false;"... the "return false" tells the browser not to continue handling the event (by submitting the form, for example). If that's not it, you might try showing us your code.

    Calling a Web Service from within JavaScript source

    I'm trying to make an internal Web Service call from within an ATLAS client control, but I can't figure out how to get the parameters passed into the call properly into the Invoke method for ServiceMethod.

    The following manages to call the Web Service but the parameter is not respected.

    var num =new Object();

    num.Value = -1;

    var serviceMethod =new Sys.Net.ServiceMethod(_serviceURL, _serviceMethod,null/*? _appUrl */);var _request = serviceMethod.invoke(num, _onMethodComplete, _onError,

    _onError,_onError,

    this,

    2000, Sys.Net.WebRequestPriority.Normal);

    Actually I can see that the object needs to be formatted with the name of the parameter. While I can do this for testing - at runtime I have no idea what service the user is connecting to so I won't know the name of the parameter. Isn't there some more generic way to call the Web Service from code?

    Also what is AppUrl in this context?

    I suspect the answer is the higher level ServiceMethodRequest, but it takes a UserContext object that I have no idea how to create.

    Any ideas appreciated.

    +++ Rick --

    The first parameter to invoke() is an object that wraps all the parameters of your server method. e.g if your server method takes an int named 'n' and a string named 's', you would have:

    serviceMethod.invoke({i:5, s:"Hello"), ...)

    David


    Ok, that's not terribly useful <g>... All of the values passed are going to be variables. Unless I parse this myself I can't see how to call the service dynamically with this scheme.

    There's gotta be a higher level mechanism for making a remote Web Service call? If not, then that's something that should maybe be there? Similar to what Callmethod used to do?

    +++ Rick --


    Not sure I'm following you. In the code above, you can replace 5 and "Hello" by arbitrary variables.

    Note that there is indeed an alternative way of calling services by using the generated proxy. See thispage for an example.


    Yeah of course I can call a Web Service that's PREDEFINED using the proxy class generated, but that doesn't help if you need to call the service when you don't know beforehand what the name is or what's exposed on it. If you want dynamic execution you won't know immediately at runtime what the parameters are or what the type.

    So yeah, I can write a string value there but if I don't know that it's a string beforehand it gets to be a major hassle to write that call.

    Consider this scenario: You build a custom client control and you have an option to call a service Url with arbitrary parameters that are set up in an array. Then you have to parse that call into this funky syntax.

    There needs to be a way to dynamically call a service the same way that CallMethod used to work.


    Yeah of course I can call a Web Service that's PREDEFINED using the proxy class generated, but that doesn't help if you need to call the service when you don't know beforehand what the name is or what's exposed on it. If you want dynamic execution you won't know immediately at runtime what the parameters are or what the type.

    So yeah, I can write a string value there but if I don't know that it's a string beforehand it gets to be a major hassle to write that call.

    Consider this scenario: You build a custom client control and you have an option to call a service Url with arbitrary parameters that are set up in an array. Then you have to parse that call into this funky syntax.It doesn't work.

    There needs to be a way to dynamically call a service the same way CallMethod used to work. So you can specify an array of values, an endpoint Url and method name.


    I do not think Macrh CTP directly provides the functionality you are looking for. But if you can exam how Sys.Data.DataSource class works. it may provide some hints if you decide to write you own class to accomplish your goal.

    Actually, the syntax above is completely generic, and requires no hard coded knowledge of any aspect of the web service. All the parameters are passed as arbitrary name/value pairs on a standard Javascript object, which can be added dynamically.

    David


    David, I think your sample code is some kind of generic, but i don't see how it works if we don't know , at design time, what public web services out there user want to call.


    Why do you think you need to have this information at design time? Every piece of the code (the URL, the method name, the parameter names and values) can be specified dynamically.

    Of course, if you are referring to the proxy class, then yes, that is only usable for the case where you know at design time what service you want to call. But the original post was not about the proxy.

    David


    Hi David,

    We seem to have some sort of disconnect here. Let me explain what I mean.

    You said:

    The first parameter to invoke() is an object that wraps all the parameters of your server method. e.g if your server method takes an int named 'n' and a string named 's', you would have:

    serviceMethod.invoke({i:5, s:"Hello"), ...)

    First is that type prefix required or not? I think I tried without it and it didn't seem to work. If it is required then the above is not generic because you'd have to parse the values into the above format and then eval it into a string somehow which is a mess.

    You say the above with such certainty, but you have to remember we're working off this stuff blind. This stuff isn't documented. We DON'T KNOW what the parameter signature is, we have to guess...

    So anything you can do to explain would be really helpful...

    Thanks,

    +++ Rick --


    Hi Rick,

    In Javascript writing { i:5, s:"hello" } creates an object that contains two fields with those name/value pairs. 'i' and 's' are not prefixes, they are field names, and in Atlas JSON services (as in SOAP) they are required since parameters are passed by name (and not by order).

    Another way to create this same object is to write:

    var o = {};
    o.i = 5;
    o.s = "hello";

    And yet another way which I think will be the one you want is:

    var o = {};
    o["i"] = 5;
    o["s"] = "hello";

    Note that that there is no need to call eval(), which would indeed be ugly (and inefficient). Does that give you what you are lookin for?

    And I certainly realize the doc is poor and samples are limited. But they'll get better! :)

    David

    Calling a simple JS Function in the "Atlas way"

    How could I, from an server-side control (like a Button), call an JS Function?
    In the "old way", I used theRegisterClientSideScriptBlock to do this, but it does not work in the Atlas.

    Thanks in Advance for the attention,
    Fract4L

    RegisterClientSideScriptBlock isn't working anymore for you with Atlas? Could you post a code sample showing the problem and describe what error you're getting if any?


    I haven't tested this with Atlas but I assume it should work. This might even be some deprecated method of calling a JS funcion from a .NET control but I would always add the following to the page_load.

    Button1.Attributes.Add("OnClick", "HelloWorld();")

    Not sure again if this will work in Atlas, but it does add the js event function to the button itself.

    JoeWeb


    hello.

    use the overload that has a boolean as its last parameter. this method will generate the correct script block in all cases (i think that you're script string has <script type='javascriopt'> on it, right? if you fo this, it won't work in atlas because only the scripts that have the type attribute set to text/javascript will be correctly loaded by the platform).

    regarding the bt click handling on the client side, you can also use the new onclientclick property intesad of using the attributes collection.


    Hello all,

    TheRegisterClientScriptBlock was deprecated in favor of the classClientScript, that has all the funcionallities of the old method and some new ones.


    Either way, thanks in advance for your fast responses and I hope that this question could help others.

    Fract4L

    Here is the code:

    1protected void btnAccess_Click(object sender, EventArgs e)2{3// this works fine ;-)4StringBuilder sb =new StringBuilder();5sb.Append("<script type=\"text/javascript\">");6sb.Append("alert('test');");7sb.Append("</" +"script>");8ClientScript.RegisterClientScriptBlock(this.GetType(),"test", sb.ToString());9}

    hello.

    i'd remove the lines <script> and </script> and add ,true to the registerclientscriptblock method.

    Monday, March 26, 2012

    Calling a control on another contentPlaceHolder...

    Hi all,

    I could not find an answer when I searched, but I assume this can be done. I'm fairly new to AJAX, but here is what I'm trying to do. I have 2 repeaters on my page. They are on seperate content panels. I have the first one set as the trigger for the second one. If I put them on the same contentPlaceHolder, this works great, but when I move the first repeater to another place holder, it blows up because it cannot find the repeater. Is there a way I can reference the first repeater if it is on another place holder?

    Here is my code. :

    <asp:Content ID="leftSide" runat="server" ContentPlaceHolderID="leftOfPage">
    <asp:Repeater ID="Repeater1" runat="server" DataSourceID="ObjectDataSource1">
    <HeaderTemplate>
    <table cellpadding="0" border="1">
    <tr>
    <th>Header Values</th>
    </tr>
    </HeaderTemplate>
    <ItemTemplate>
    <tr>
    <td>ItemValues</td>
    </tr>
    </ItemTemplate>
    <FooterTemplate>
    </table>
    </FooterTemplate>
    </asp:Repeater>

    <asp:ObjectDataSource ID="ObjectDataSource1" *rest of parameters here*>
    </asp:ObjectDataSource>
    </asp:Content>

    <asp:Content ID="rightSide" runat=server ContentPlaceHolderID="rightSideOfPage">
    <asp:ScriptManager ID="ScriptManager1" runat="server" ></asp:ScriptManager>
    <asp:UpdatePanel ID="updateOnClick" runat="server" EnableViewState="true">
    <ContentTemplate>
    <asp:Repeater ID="Repeater2" runat="server">
    <HeaderTemplate>
    <table cellpadding="0" border="1">
    <tr><th>Header Values</th></tr>
    </HeaderTemplate>
    <ItemTemplate>
    <tr>
    <td>Item Values</td>
    </tr>
    </ItemTemplate>
    <FooterTemplate></table></FooterTemplate>
    </asp:Repeater>
    </ContentTemplate>
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="Repeater1" />
    </Triggers>
    </asp:UpdatePanel>
    </asp:Content>

    Thanks!

    Hmm, why do you even use two content for? Why don't you use table or two update panels?

    Anyway, try this:

    Add a hidden textbox in your second Content. When the repeater from the first content rebind or during it's PreRender, you set a value (any value) inside that hidden textbox.

    On your second Content:
    Use your trigger to aim at the hidden textbox id.

    <Triggers><asp:AsyncPostBackTrigger ControlID="textbox_id" EventName="TextChanged" /></Triggers>


    hope it works.

    p.s. for debugging, don't hide your textbox, because you want to see if the value is set during the PReRender of the first repeater.


    Thanks WishStar. The two content placeholders come from my masterpage. In order to maintain consistency throughout the site, I have 4 content placeholders on my master page. Maybe this is improper use of the masterpages (as I'm quite new to them), but I put one in for the header, footer left and right sides of the page. Using placeholders any page can overwrite them if need be, otherwise they see what is on the masterpage. It actually is working quite smoothly, except the issue outlined above.

    I did get around the issue using the FindControl() method, but this means I have a hardcoded control name in my code which will compile whether the control exists or not. I don't like this, so I will try out what you mentioned above. Thanks!

    Rubes

    Callback for dynamic populate control

    When I call the populate method of dynamicpopulator control it calls the method as set in the ServiceMethod property.

    How do i know when this method has completed execution so that I could perform some other task.

    Is there a callback that I can access that tells me that the populate method has completed?

    Please advise.

    There might be a way to access the callback handler of the webservice proxy that gets invoked, but I'd say that an easier way would be to use the CustomScript property to call a function of your own design which returns to a handler you set up to do what you're looking for.

    Saturday, March 24, 2012

    Call a JS function on AJAX update (instead of using UpdateProgress control)

    The atlas:UpdateProgress control is nice, but an app I am working on already has a "loading..." image that is displayed using JavaScript (displayLoader(), and hideLoader() to hide) whenever a "non-Atlas" postback is invoked, and when the page initially starts loading.

    I am looking for an way to call these functions whenever an Atlas postback is made so I can use this functionality for both types of postback. Is there an way to do this with client script, rather than creating a custom version of the UpdateProgress control?

    Regards,
    David

    You should check out the samples on the client atlas section.

    You can handle the different events to create your own custom progress indicator.


    hello.

    once again, search the atlas discussion an suggestion forum. there you'll find 1 or 2 posts that show how to handle the propertychanged event of the pagerequestmanager in order to handle the start and end of a partial atlas postback with jscript.


    Great, those keywords have helped turn up some good results. I was previously searching both here and search engines for terms relating to "custom atlas updateprogress control" and didn't have much luck.

    Thanks for pointing me in the right direction.
    Regards,
    David

    Calenderextender problem

    when I use the CalenderExtender with a html button as popupbutton and a asp.net text field as target control it works fine. but the problem is when the calender becomes visible if there are any dropdownlist then it is on the calender. so part of the calender becomes invisible. i.e. goes behind the DropDownList.

    but if there is a textbox in the position of the DropDownList then everything works fine.

    how do i solve this issue? Any idea?

    Hi

    I'm afraid that it's a normal thing and no solution yet,just avoid it.

    Best regards

    CalenderExtender not working when TextBox is not empty

    Hi

    I was testing the CalendarExtender control and it worked fine but only if the TextBox was empty. I'm guessing this is a bug...! Does anyone know how to fix it?

    Cheers

    I hv d same problem

    Calender

    not working if applyinf the format to

    Calender

    <

    cc2:CalendarExtenderID="CalendarExtender1"runat="server"PopupButtonID="Image1"TargetControlID="txtdob"Format="dd-MMM-yyyy"></cc2:CalendarExtender><asp:TextBoxID="txtdob"runat="server"></asp:TextBox><asp:ImageID="Image1"runat="server"ImageUrl="~/images/Calendar_scheduleHS.png"/>

    and behind code

    txtdob.Text = myDate.

    ToString("dd-MMM-yyyy");

    if txtdob is already filled during page load

    Calender Question

    Hey, All my calender inputs are done with the ajax calender control, only problem is all the dates are coming up "American-style" ie MMMM d YYYY, is there a bit of code that`ll format this correctly? i just want the date to look like (if its today for instants) 16/07/07

    Thanks in advance si!

    You can set the format property to "dd/MM/yy" 
    <ajaxToolkit:Calendar runat="server" TargetControlID="Date1"CssClass="ClassName"Format="dd/MM/yy"PopupButtonID="Image1" />

    When i went to update the test date i got the error :

    The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

    Is there a way of formatting the data in the database ? Si!


    Here is a link that will help you to format in SQL

    http://www.sql-server-helper.com/tips/date-formats.aspx

    Calender hide onBlur problem

    I know that the calendar extender is suppose to hide when you click outside of the control, but it's not for me. I'm using the calendar control in association with a button. Both the button and the control are being added dynamically to the page. The follow is the code used to build these controls.

    oNewImage =New Image

    oNewImage.EnableViewState =True

    oNewImage.TabIndex = 0

    oNewImage.CssClass ="CalendarPopup"

    oNewImage.ID ="CalendarPopup" &CInt(glintCountCalendarImage)

    oNewImage.ImageUrl ="..\images\CALENDAR.ICO"

    oNewImage.Visible =True

    oNewAjaxCalendar =New AjaxControlToolkit.CalendarExtender

    oNewAjaxCalendar.TargetControlID = oNewTextBox.ID.ToString

    oNewAjaxCalendar.OnClientShowing ="showingCalendar"

    oNewAjaxCalendar.PopupButtonID = oNewImage.ID.ToString

    oNewAjaxCalendar.Format ="MMddyy"

    oNewAjaxCalendar.CssClass ="icmsCalendar"

    oNewAjaxCalendar.PopupPosition = AjaxControlToolkit.CalendarPosition.BottomRight

    oNewAjaxCalendar.ID ="AJAXCALENDAR" &CInt(glintCountCalendarImage)

    oNewAjaxCalendar.OnClientDateSelectionChanged ="hideCalendar"

    oNewTextBox.Attributes.Add("JUSTIFY","RJ")

    oWebForm.Controls.Add(oNewImage)

    oWebForm.Controls.Add(oNewAjaxCalendar)

    Hi James,

    Use an ImageButton instead of an Image!

    Let me know how that works out ;)
    Kind regards,
    Wim

    Calender control positioning problem

    I have got two issues with calender control

    1)I have body scroll="no" and div's overflow to auto(as i have menu in top div locked and content page in other div) When i use calender control the position of popup is offset to the targetcontrolid i.e it is not docked below targetcontrol id. TargetControl is at the bottom of div so user has to scroll to reach that control. Is there any way to render the popup aligned with targetcontrol as it is done when body scroll="yes". I have also tried with body's style="overflow-y:hidden" and got same offset issue.

    2) In addition to above scenario, if i have dropdownlist below target control, than calender control seems to be hidden partially. Is there any way to set z-index so that calender control will always be rendered on top of dropdownlist.

    It's the divs that are controling where the calendar is position. Did you play with the absolute value? That will let you add the calendar wherever you want in the page, the only control that has problems positioning with divs is the dropdown in IE6. Do you want me to send you some div code?
    sure you can send me the code...i will highly appreciate that..

    Calender Control in IE 5.5

    I have a Calender control on my site and when people access using IE 5.5 the browser crashes most of the time. When it does not crash it says something about the scripts causing the browser to run slow.

    Are the AJAX controls compatable with IE 5.5?

    many people have said similar things with ie 5.5

    the OFFICIAL list of compatible browsers unfortunately starts at IE 6

    http://www.asp.net/ajax/documentation/live/BrowserCompatibilityForASPNETAJAX.aspx

    hth,

    mcm

    Calender control in asp.net

    Hi, Could anyone please tell me how can i display datepicker when i click textbox or button and i want the date to be in textbox.

    could any one give me code to do thhis? i have master page in my project

    Thanks for any assistance

    Have a look at the ASP.NETAJAX Calendar control.


    Hi Tweety,

    If you want use CalendarExtender, please download theAjax Control Toolkit. And some pretty samples are contained inside the package.

    I hope this help.

    Best regards,

    Jonathan


    Hi. thanks for both of you

    im using ajax calender tool kit, jus searchin for good design(i mean css) to apply.

    if u have any please suggest me.

    thanks again


    It really depends on your application as to what style to apply, but if you read thecalender page (specifically the theming section) it will show you how you can customize it to suit your application.


    <asp:TextBoxID="TextBox5"runat="server"Width="120px"CssClass="textile"></asp:TextBox></td>

    <cc1:CalendarExtenderrunat=serverTargetControlID=textbox5Format="dd/MM/yyyy">

    </cc1:CalendarExtender>

    im using this code.i have a pblm here once i selected date my date appears in textbox but the calender still can able to see until i clik some where on the page...

    why like this?


    That's how the control has been built. View thecalendar page for 3 different examples on how it behaves.


    Hi Tweety,

    If you want to hide the Calendar immediately after we selected a date, you should add thisOnClientDateSelectionChanged="function hideCalendar(cb) { cb.hide(); }" to your source code. OnClientDateSelectionChanged is one property of the CalendarExtendar.

    Hope this helps.

    Best regards,

    Jonathan


    Hi thanks but once a date is selected calender hide , but when i reclick the textbox it wont appears...

    did i need to quote another javascript here to make calender visible when i click textbox after date selection?


    Its fixed...thanks.

    http://forums.asp.net/t/1067091.aspx?PageIndex=2

    i found my soluntion here..

    thanks for everyone.

    forums.asp.net ROCKS!!!!

    Calender Control

    Hi,

    i am using ajax controls in asp.net.and the problem is with calender control,when i run the application the controls goes behind the text boxes.so whats will be he solution???

    Regards ASAD

    Just a quickie idea but what if you change the z-index in the styles? will that help?


    Hi Asadikram02,

    Has your problem been resolved yet ? This kind of issue often occurs on select control and we resolve it by identify its z-index property. Here is the Article which shows the solution. http://support.microsoft.com/default.aspx?scid=kb;en-us;177378

    <script>
    function setindex()
    {
    div1.style.zIndex=text1.value;
    select1.style.zIndex=text2.value;
    getindexes();
    }

    function getindexes(){

    text1.value=div1.style.zIndex;
    text2.value=select1.style.zIndex;
    text3.value=5;
    }
    </script>
    Above is a sample to set the z-index for a select control. It is similar to your problem.

    If it doesn't work , please post your simple sample which contains this issue. Thanks

    Best regards,

    Jonathan

    calender control

    well the ajax calender control goes behind the text boxes ...so whats will be the solution

    Hi Asadikram02,

    This question has been answered athttp://forums.asp.net/p/1153988/1893050.aspx#1893050.

    This kind of issue often occurs on select control and we resolve it by identify its z-index property. Here is the Article which shows the solution. http://support.microsoft.com/default.aspx?scid=kb;en-us;177378

    Best regards,