<html dir="LTR"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" /> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5" /> <title>P4Connection.OnPrompt Event</title> <xml> </xml> <link rel="stylesheet" type="text/css" href="MSDN.css" /> </head> <body id="bodyID" class="dtBODY"> <div id="nsbanner"> <div id="bannerrow1"> <table class="bannerparthead" cellspacing="0" id="Table1"> <tr id="hdr"> <td class="runninghead">Perforce API for the .Net CLR</td> <td class="product"><img alt="P4.Net" src="p4net.GIF" /></td> </tr> </table> </div> <div id="TitleRow"> <h1 class="dtH1">P4Connection.OnPrompt Event </h1> </div> </div> <div id="nstext"> <p> Raised when Perforce is prompting for a response. </p> <div class="syntax"> <span class="lang">[VisualBasic]</span> <br />PublicEventOnPromptAs<a href="P4API.OnPromptEventHandler.html">OnPromptEventHandler</a></div> <div class="syntax"> <span class="lang">[C#]</span> <br />publicevent<a href="P4API.OnPromptEventHandler.html">OnPromptEventHandler</a>OnPrompt;</div> <p> </p> <h4 class="dtH4">Event Data</h4> <p>The event handler receives an argument of type <a href="P4API.P4PromptEventArgs.html">P4PromptEventArgs</a> containing data related to this event. The following <B>P4PromptEventArgs</B> properties provide information specific to this event.</p> <div class="tablediv"> <table class="dtTABLE" cellspacing="0"> <tr valign="top"> <th width="50%">Property</th> <th width="50%">Description</th> </tr> <tr VALIGN="top"> <td width="50%"> <a href="P4API.P4PromptEventArgs.Message.html">Message</a> </td> <td width="50%"> The message from Perforce. </td> </tr> <tr VALIGN="top"> <td width="50%"> <a href="P4API.P4PromptEventArgs.Response.html">Response</a> </td> <td width="50%"> The value to respond to Perforce with. </td> </tr> </table> </div> <h4 class="dtH4">Remarks</h4> <p>Handle Perforce "prompts". Prompts are from commands that ask the user to respond, such as: <list> <li>login</li> <li>passwd</li> <li>resolve (without an -a* switch)</li> </list> </p> <h4 class="dtH4">Example</h4> <p> The following sample will change the user's password. <pre class="code" language="C#" escaped="true">public class PasswordSetter { private P4Connection _p4 = null; private string _oldPassword = ""; private string _newPassword = ""; PasswordSetter(P4Connection p4) { _p4 = p4; } public void SetPassword(string OldPassword, string NewPassword) { OnPromptEventHandler eh = new OnPromptEventHandler(OnPrompt); _p4.OnPrompt += eh; _oldPassword = OldPassword; _newPassword = NewPassword; //run passwd P4UnParsedRecordSet r = _p4.RunUnParsed("passwd"); //Clear the event just in case _p4.OnPrompt -= eh; //Clear the passwords from memory _newPassword = ""; _oldPassword = ""; } private void OnPrompt(object sender, P4PromptEventArgs e) { switch (e.Message) { case ("Enter old password: "): e.Response = _oldPassword; break; case ("Enter new password: "): e.Response = _newPassword; break; case ("Re-enter new password: "): e.Response = _newPassword; break; } } } </pre> </p> <h4 class="dtH4">See Also</h4> <p> <a href="P4API.P4Connection.html">P4Connection Class</a> | <a href="P4API.html">P4API Namespace</a></p> <object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e" viewastext="true" style="display: none;"> <param name="Keyword" value="OnPrompt event"> </param> <param name="Keyword" value="OnPrompt event, P4Connection class"> </param> <param name="Keyword" value="P4Connection.OnPrompt event"> </param> </object> <hr /> <div id="footer"> <p> <a href="Copyright.html">Copyright 2006 Shawn Hladky</a> </p> <p> </p> </div> </div> </body> </html>
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 7341 | Erik Purins |
p4.net --- pull p4.net#head |
||
//guest/shawn_hladky/P4.Net/release/0.9/doc/html/P4API.P4Connection.OnPrompt.html | |||||
#1 | 5831 | Shawn Hladky | P4.Net: Branch release 0.9 and delete a few files missed last time | ||
//guest/shawn_hladky/P4.Net/main/doc/html/P4API.P4Connection.OnPrompt.html | |||||
#1 | 5830 | Shawn Hladky | P4.Net: reorg to support release branches | ||
//guest/shawn_hladky/P4.Net/doc/html/P4API.P4Connection.OnPrompt.html | |||||
#1 | 5812 | Shawn Hladky | P4.Net: More documentation. |