Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Learning to use JavaScript with ASP.Net
Message
De
20/05/2009 09:16:55
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
20/05/2009 04:56:15
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
ASP.NET
Application:
Web
Divers
Thread ID:
01400821
Message ID:
01400918
Vues:
49
Thanks Viv,

I do not have a grasp on this. Are you saying a browser can respond to an event? So much to learn in this realm.
tim

>>Hi All,
>>
>>I have searched through book titles and many that I own only to find I don't have any good tutorials or reading on how to effectively use(learn) javascripting. I am paticuraly interested in learning how to navigate through controls with no intelisense, how to use hidden fields and access them both from the server side C# as well as from a javascript function. How to cause a postback from javascript and how to cause javascript to run from serverside method or code after a postback. Does anybody have any suggestions for good reading or tutorials on these topics?
>>
>>Right now I would like to do the following:
>>Within a javascript event set a variable of some sort on the client side indicating a condition.
>>Then cause a postback to server side code from this same function.
>>When the postback finished, I need to have another javascript function execute to check if this variable is true and if so
>>I can perform some additonal work on the client.
>>I have been trying to find information on doing this type of stuff with no luck.
>>
>>I really need to find a good book or tutorial on how these types of things can be accomplished.
>
>Can't recommend a book. I use a webservice for something similar. Basic pattern is:
> <script type="text/javascript">
>
>        function GetKeyInfo() {
>            var KeyCode = document.getElementById("txtIncomingCode").value;
>            MyServer.SAWebServices.GetKeyInfo(KeyCode, OnGetKeyInfoSucceeded);
>        }
>
>        function OnGetKeyInfoSucceeded(result) {
>                document.getElementById("txtIncomingCode").value = result.FormattedCompanyCode;
>                document.getElementById("lblKeyInfo").innerHTML = "Site Id: " + result.SiteId
>                 + " Seq: " + result.Sequence
>         }
></script>
><body>
>        <asp:TextBox ID="txtIncomingCode" runat="server"></asp:TextBox>
>        <input id="btnClean" type="button" value="Verify" onclick="GetKeyInfo()" /><br />
></body>
>
The button fires the GetKeyInfo() call to the webservice. OnGetKeyInfoSucceeded is the callback that fires when the response is received from the server. In this case the webservice returns a class instance with just three public string properties. You can access the class members directly in Javascript. But remember that you can't rely on session state in the webservice.
>(Above is not complete code - elements missing from body....)
>OTOH, you could look at using the AJAX UpdatePanel?
Timothy Bryan
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform