Wrox Professional Web Parts and Custom Controls with ASP.NET 2.0 phần 7 pptx

45 394 0
Wrox Professional Web Parts and Custom Controls with ASP.NET 2.0 phần 7 pptx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Dynamically Generating Code The next step up the evolutionary ladder of client-side code writing is to dynamically generate your code and insert it into your page. The first step in generating dynamic client-side code is to prepare, in your server-side code, the client-side code to be added to the page and concatenate it into a string variable. The range of code that you can build is infinite, but I’ll stick to the simple SayHello example. This Visual Basic 2005 example puts the SayHello program into a single string: Dim strSayHello As String strSayHello = “<script>function SayHello(){window.alert(“ & _ “‘Hello, World’);}</script>” In C#: string strSayHello; strSayHello = “<script>function SayHello(){window.alert(“ + “‘Hello, World’);}</script>”; Even if your code is being generated dynamically, it’s often a good idea to write an initial, static version of the code in the Source view of your page. This gives you all the IntelliSense support of the Visual Studio 2005 editor plus some syntax checking. It’s also a good idea to do some testing with your static code before cutting the code out of your page and incorporating it into your server-side code. The next step is to add this routine to your page from your server-side code. The simplest way to do this is to use the Response object’s Write method, as this Visual Basic 2005 version does: Me.Page.Response.Write(strSayHello) In C#: this.Page.Response.Write(strSayHello); However, there are two problems with this method. The first problem is that you have very little control over where the client-side code is added. Used from the Page_Load event of a WebForm, for instance, the script block is inserted ahead of the HTML and DOCTYPE tags that begin your Web page (the code still executes in Internet Explorer, however). Typically, there are two places where you want to put your script: ❑ At the head of the form, so that the code is guaranteed to have been processed by the browser by the time the user works with the control that the code is associated with ❑ At the end of the form, so that the code can’t execute until all of the controls have been successfully loaded The second problem with using Reponse.Write to add your client-side code to the page is: How do you prevent different copies of your control repeatedly adding the script block to the page? For instance, if you create a control that adds client-side code, there is nothing stopping the developer using your control from putting two or more copies of your control on the page that she is building. If both copies of your control insert client-side code into the page, the results of executing the code are going to be difficult to predict but almost certainly won’t be what you want. 253 Adding Advanced Functionality 15_57860x ch09.qxd 10/4/05 9:22 PM Page 253 The answer to this second problem is to treat the script block in a page as a “library” block: the block contains a variety of useful routines that may be called from all the copies of the control on the page. All you need to do is ensure that, after your library block is added to the page at least once and that no other control adds the library again. Both the problems of controlling the placement of your code and preventing code from being added sev- eral times are handled by the RegisterClientScriptBlock and the RegisterStartUpScript methods of the ClientScriptManager object, which has methods for supporting most client-side scripting activities. You can retrieve the ClientScriptManager for a page from the Page object’s ClientScript property. The difference between the two methods is where the code is placed: ❑ RegisterClientScriptBlock puts the code immediately after the form open tag that starts the form on your page. ❑ RegisterStartUpScript puts the code just before the form close tag that ends the form on your page. RegisterStartUpScript can be used to add script blocks that contain code that isn’t in routines— in other words, code that executes as part of the page load process. Because the RegisterStartUpScript code is placed at the end of the form, the controls on the form will have been loaded and be available for processing from your client-side code. This makes RegisterStartUpScript a good choice to add any code that you want to execute before the user has taken any action (such as code to position the cursor in some field when the page is first displayed). Both of the Register* methods accept four parameters: ❑ A system type: For this parameter you just need to pass the type of your custom control. This parameter allows ASP.NET to keep scripts from different controls separate. ❑ The key for the script block: This key allows ASP.NET to check whether the script block has already been added. ❑ The script itself: This parameter is concatenated into a single string. ❑ A Boolean value: A value that indicates, when True, that this script should be placed inside a <script> element. If you set this parameter to False, you’ll need to include the <script> element in your code. This parameter is optional and defaults to False. If you are generating script blocks for constituent controls, you still want to pass the type of your cus- tom control to the Register* event rather than your constituent controls. While your custom control is a unique type, your constituent controls are more likely to be the relatively common TextBoxes, ListBoxes, and other ASP.NET controls. As you’ll see in this section, the Page’s ClientScriptManager object has a number of methods that are useful when generating client-side code. In ASP.NET 1.x some of the methods were available directly from the Page object (RegisterClientScriptBlock and RegisterStartUpScript are two examples). However, those versions of the methods are now marked as obsolete and you should use the versions available from the ClientScriptManager object. 254 Chapter 9 15_57860x ch09.qxd 10/4/05 9:22 PM Page 254 This Visual Basic 2005 example places the code for the SayHello routine at the start of the form inside a <script> element: Dim csm As System.Web.UI.ClientScriptManager csm = Me.Page.ClientScript csm.RegisterClientScriptBlock(Me.GetType, “PHVBlock”, strSayHello, True) In C#: System.Web.UI.ClientScriptManager csm; csm = this.Page.ClientScript; csm.RegisterClientScriptBlock(this.GetType(), “PHVBlock”, strSayHello, true); The resulting JavaScript code looks like this: <script type=”text/javascript”> <! function SayHello(){window.alert(‘Hello, World’);}// > </script> When adding code to your page, you’ll frequently want to incorporate the name of your control into your code. You can retrieve the name of your control at run time from your control’s UniqueId property, as discussed in Chapter 3. If you want your client-side code to manipulate the HTML structure that wraps a Web Part, see Chapter 5 for a description of a Web Part’s HTML structure. In addition to the ClientScript object’s RegisterClientScriptBlock and RegisterStartupScriptBlock, you can also use the RegisterOnSubmitStatement to add code to your page. The RegisterOnSubmitStatement adds a script block to your host page that isn’t tied to any particular control but executes just before the page is posted back to the server. This Visual Basic 2005 example associates the SayHello routine with the submit event of the page: Dim csm As System.Web.UI.ClientScriptManager csm = Me.Page.ClientScript csm.RegisterOnSubmitStatement(“PHVSubmitBlock”, strSayHello) In C#: System.Web.UI.ClientScriptManager csm; csm = this.Page.ClientScript; csm.RegisterOnSubmitStatement(“PHVSubmitBlock”, strSayHello); The key that you use when adding a script block allows you to check whether the block has already been added by using the Page’s IsClientScriptBlockRegistered method (similar Is*Registered methods check for the results of other Register* methods). Passed the key for a script block, the IsClientScriptBlockRegistered method returns True if a client script block with that key has already been added to the page. 255 Adding Advanced Functionality 15_57860x ch09.qxd 10/4/05 9:22 PM Page 255 This Visual Basic 2005 code takes advantage of the method to avoid adding the SayHello routine if it’s already been added: Dim csm As System.Web.UI.ClientScriptManager csm = Me.Page.ClientScript If csm.IsClientScriptBlockRegistered(“PHVBlock”) = False Then csm.RegisterClientScriptBlock(“PHVBlock”, strSayHello) End If In C#: System.Web.UI.ClientScriptManager csm; csm = this.Page.ClientScript; if(csm.IsClientScriptBlockRegistered(“PHVBlock”) == false) { csm.RegisterClientScriptBlock(“PHVBlock”, strSayHello); } Four other notes on using the Register* methods: ❑ Using the Is*Registered methods is optional. The Register* methods don’t add anything if an item with the same key has already been added (and no error will be raised). ❑ You must call the Register* methods before the Render method (that is, in the PreRender event or earlier). ❑ All scripts added with any one of the Register methods go into the same <script> element. For instance, all the script code added with the RegisterClientScriptBlock goes into the same <script> element at the start of the form. ❑ The keys assigned in the RegisterClientScriptBlock, RegisterOnSubmitBlock, and RegisterStartupScript are kept separate from each other. If you add a script block with the key “PHVBlock” with RegisterClientScriptBlock, it won’t prevent adding a block with the same key using one of the other Register* methods. Support for Client-Side Script ASP.NET provides several other tools to support client-side processing. The following subsections cover these other tools. Adding Arrays While your server-side code has access to databases on your server, code executing in the browser does not. The usual solution to this problem is to extract the data from the database in your server-side code and embed that data in a static array in the client-side code. The RegisterArrayDeclaration method not only adds the necessary array to the page, but also flags the array has being added. As a result, controls that share data (for instance, a list of valid customer codes) can avoid adding the data twice. 256 Chapter 9 15_57860x ch09.qxd 10/4/05 9:22 PM Page 256 The RegisterArrayDeclaration accepts two parameters: ❑ The name of the variable that holds the array in the client-side code ❑ The string that is used to initialize the array In this Visual Basic 2005 example, an array called CustStatus is created with four entries ('Rejected', 'Standard', 'Gold', 'Platinum'): Dim csm As System.Web.UI.ClientScriptManager csm = Me.Page.ClientScript csm.RegisterArrayDeclaration(“CustStatus”, _ “‘Rejected’, ‘Standard’, ‘Gold’, ‘Platinum’”) In C#: System.Web.UI.ClientScriptManager csm; csm = this.Page.ClientScript; csm.RegisterArrayDeclaration(“CustStatus”, “‘Rejected’, ‘Standard’, ‘Gold’, ‘Platinum’”); The resulting JavaScript code looks like this: <script type=”text/javascript”> <! var CustStatus = new Array(“Rejected”, “Standard”, “Gold”, “Platinum”); // > </script> Client-Side Includes Rather than include all the client-side code in the page, a common practice is to place the client-side code in a separate file and reference this file using a <script> tag with an src attribute. The RegisterClientScriptInclude method allows you to add this kind of script tag to reference a script file. This Visual Basic 2005 example adds a reference to a code file called code.js: csm.RegisterClientScriptInclude(“PHVBlock”, “code.js”) In C#: csm.RegisterClientScriptInclude(“PHVBlock”, “code.js”); The resulting <script> element looks like this: <script src=”code.js” type=”text/javascript”></script> 257 Adding Advanced Functionality 15_57860x ch09.qxd 10/4/05 9:22 PM Page 257 Using Include files provides a way of implementing the strategy to provide clients with only the client- side code that they can support. It’s not unusual to have a set of client-side code that works, for instance, in the latest version of Netscape Navigator but does not work in earlier versions without some modification. To handle these differences, write a version of code for each browser that you intend to support and put each version in a different file. At run time, check the browser type with the BrowserCapabilities object and use RegisterClientScriptInclude to add a reference to the script file that contains code that works on that browser. The convention for ASP.NET 2.0 is to keep client-side resources (like a script file) in a virtual directory in the root of the Web server called aspnet_client (this virtual directory is created when ASP.NET 2.0 is assigned). You should install your client-side resources: ❑ In aspnet_client ❑ In a subfolder named for your application ❑ In a further subfolder based on the version number of the application For example, the client-side code file called code.js for version 1.0.0.0 of an application called MyApplication would go in the folder /aspnet_client/MyApplication/1_0_0_0/. However, rather than keep resources in separate files, you can insert the code file directly into your application’s assembly. To embed a file in your application’s assembly, just add the file to your project and then (in the file’s Properties List) set the file’s Build Action to Embedded Resource. A utility program called WebResource.axd (distributed with the .NET Framework) handles retrieving the embedded resources when requested with a query string that specifies the resource. The RegisterClientScriptResource method generates a script tag with an src attribute that references the WebResource utility and retrieves the resource. This Visual Basic 2005 example retrieves a resource called code.js: csm.RegisterClientScriptResource(Me.GetType, “code.js”) In C#: csm.RegisterClientScriptResource(this.GetType(), “code.js”); The resulting page would contain this tag: <script src=”/WebPartsHostVB/WebResource.axd?d=WylyhFDzry8iRJrQJB9A0hZkD_GD3HHX8pJs r0kUntA1&amp;t=632482109977226208” type=”text/javascript”></script> You can also generate the URL for any resource by using the GetWebResourceURL method, passing the same parameters that you would use to create the resource. This allows you to embed the URL into other attributes than the script tag generated by RegisterClientscriptResource. This Visual Basic 2005 code, for instance, adds the URL to a custom attribute for the control as part of rendering the control’s URL: Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter) writer.AddAttribute(“type”, “text”) writer.AddAttribute(“id”, “txtName;”) writer.AddAttribute(“MySrc”, Me.Page.ClientScript. _ 258 Chapter 9 15_57860x ch09.qxd 10/4/05 9:22 PM Page 258 GetWebResourceURL(Me.GetType,”code.js”)) writer.RenderBeginTag(“input”) writer.RenderEndTag() End Sub In C#: protected override void Render(System.Web.UI.HtmlTextWriter writer) {writer.AddAttribute(“type”, “text”); writer.AddAttribute(“id”, “txtName;”); writer.AddAttribute(“MySrc”, this.Page.ClientScript. GetWebResourceURL(this.GetType, “code.js”)); writer.RenderBeginTag(“input”); writer.RenderEndTag(); } Expando Attributes As the previous example suggested, you can define your own attributes to be added to tags (called expando attributes). Expando attributes are implemented as a set of client-side code that is called by the browser when it finds the attribute on a client. The ClientScriptManager’s RegisterExpandoAttribute method supports adding the client-side code expando attributes. This Visual Basic 2005 code creates an attribute called EncryptionMethod to be used with <input> tags and sets the attribute’s initial value to SHA1: csm.RegisterExpandoAttribute(“input”, “EncryptionMethod”, “SHA1”) In C#: csm.RegisterExpandoAttribute(“input”, “EncryptionMethod”, “SHA1”); The resulting JavaScript code looks like this: <script type=”text/javascript”> <! var input = document.all ? document.all[“input”] : document.getElementById(“input”); input.EncryptionMethod = “SHA1”; // > </script> While this code defines the EncryptionMethod attribute, you still need to add the EncryptionMethod attribute to a tag in your page. You can add attributes to your control (or its constituent controls) using the Attributes collection of a control or one of the methods discussed in Chapter 3 for manipulating attributes on a custom control. Hidden Fields Often, client-side code takes advantage of HTML hidden fields (<input> tags with the type attribute set to “hidden”). The RegisterHiddenField adds an HTML hidden field to your page and sets it to some initial value while ensuring that only one copy of the hidden field is inserted. This Visual Basic 2005 code creates a hidden field called BuildQueryString and gives that field an initial value of "?": 259 Adding Advanced Functionality 15_57860x ch09.qxd 10/4/05 9:22 PM Page 259 csm.RegisterHiddenField(“BuildQueryString”,”?”) In C#: csm.RegisterHiddenField(“BuildQueryString”,”?”); The resulting HTML looks like this: <input type=”hidden” name=”BuildQueryString” id=”BuildQueryString” value=”?” /> Building CallBack Functions An important new feature in ASP.NET 2.0 is the capability to create callback functions in client-side code. A callback function is a client-side routine that can call a piece of server-side code and get data back from the server-side code. Client callbacks are supported on most modern browsers (for example, Internet Explorer 6.x+, Firefox 1.x+, Netscape Navigator 1.x+, and Safari 1.x+). Using callback functions to retrieve data from the server eliminates the need to embed arrays of server- side data into your client-side code. Instead, when the client needs the information, code on the client can call a routine on the server that retrieves the data and passes it back to the client. A typical scenario is to validate a customer number entered in the browser against a database on the server: The user enters some data (including the customer number) into various text boxes in the page and then clicks a button to submit the form. At that point, the processing sequence for a client-side callback is: 1. A function (named RaiseCallbackEvent) in your server-side code is called and passed the value of one variable in the client-side code. You need to add the client-side code to your page to ensure that the customer number is stored in the variable before the server-side code is called. 2. Your RaiseCallbackEvent executes and returns a value. In this example, your RaiseCallBackEvent returns either True or False, depending on whether the customer number is found in the customer table. 3. The value returned by the RaiseCallback event is passed to a client-side routine, which can take whatever action seems appropriate. I’ll now look at implementing this functionality. Before looking at any of the server-side code, I’ll show you the client-side code which ensures that the right data is sent to the server and that the results of the server-side processing are handled when the data is returned to the client. Then I’ll then look at the server-side code that receives the data from the client and returns a result. Finally, I’ll show you how to configure the client so that the server-side code will be called at the right time. Passing Client-Side Data Before looking at the code required to implement the callback, let’s look at the client-side code needed to ensure the data that your server-side code needs is available. Because only the value of a single client- side variable is passed to your server-side routine, you need to ensure that the variable has been added to your client-side code and set to the correct value. 260 Chapter 9 15_57860x ch09.qxd 10/4/05 9:22 PM Page 260 To support the customer number validation scenario, one solution is to declare a client-side variable that is set to the customer number when the user tabs out of the txtCustomerNumber text box. The page in the browser would look something like this: <script> var custid; function CustomerNumber_onBlur() { custid = document.all.txtCustomerNumber; } <script> <input type=”text” id=”txtCustomerNumber” onblur=”CustomerNumber_onBlur()” The code in the CreateChildControl method to insert the client-side script into the page, create the txtCustomerNumber text box, and set the text box’s onblur event to call the client-side routine looks like this in Visual Basic 2005: Protected Overrides Sub CreateChildControls() Dim csm As Web.UI.ClientScriptManager Dim txt As New Web.UI.WebControls.TextBox Dim strLoadData As String = “var custid;” & _ “function CustomerNumber_onBlur() {“ & _ “custid = document.all.txtCustomerNumber.value;}” csm = Me.Page.ClientScript csm.RegisterClientScriptBlock(Me.GetType, “loadCustid”, strLoadData, True) txt.ID = “txtCustomerNumber” txt.Text = “” txt.Attributes(“onblur”) = “CustomerNumber_onBlur();” Me.Controls.Add(txt) End Sub In C#: protected override void CreateChildControls() { Web.UI.ClientScriptManager csm; Web.UI.WebControls.TextBox txt = new Web.UI.WebControls.TextBox(); string strLoadData = “var custid;” + “function CustomerNumber_onBlur() {“ + “custid = document.all.txtCustomerNumber.value;}”; csm = this.Page.ClientScript; csm.RegisterClientScriptBlock(this.GetType(), “loadCustid”, strLoadData, true); txt.ID = “txtCustomerNumber”; txt.Text = “”; txt.Attributes[“onblur”] = “CustomerNumber_onBlur();”; this.Controls.Add(txt); } 261 Adding Advanced Functionality 15_57860x ch09.qxd 10/4/05 9:22 PM Page 261 Accepting Server-Side Results The next step is to create the client-side routine that is called after your server-side code executes. The routine must accept a single parameter that is set to the value returned from your server-side routine. As an example, this client-side code checks the parameter passed to it and displays a message if the parameter is False: <script> var custid; function ReportCustId(IsCustValid) { if (isCustValid == false) { window.alert(“Invalid customer number”);} } </script> The Visual Basic 2005 code to add this routine to the client looks like this: Dim strCallBack As String = _ “function ReportCustId(IsCustValid) {“ & _ “ if (isCustValid == false) {“ & _ “window.alert(‘Invalid customer number’);}}” csm.RegisterClientScriptBlock(Me.GetType, “callback”, strCallBack, True) In C#: string strCallBack = “function ReportCustId(IsCustValid) {“ + “ if (isCustValid == false) {“ + “window.alert(‘Invalid customer number’);}}”; csm.RegisterClientScriptBlock(this.GetType(), “callback”, strCallBack, true); Implementing Server-Side Processing With most of the client-side code in place, you can turn your attention to writing the server-side code that accepts the client-side value and returns a value to your client-side routine. In order for your control to take advantage of client callbacks, the control must implement the System.Web.UI.ICallbackEventHandler interface and then implement the RaiseCallbackEvent method and the GetCallBackResult function that are part of the interface. The RaiseCallbackEvent method is called from the client and is passed the data set in the client-side code. Here’s a Visual Basic 2005 example of a RaiseCallbackEvent function that tests the CustId passed to the routine and sets the strCustFound string to “true” or “false” depending on the results (the reason for setting a class-level variable in the RaiseCallbackEvent method will be clear shortly): Public Class MyControl _ Inherits System.Web.UI.WebControls.WebControl Implements System.Web.UI.ICallbackEventHandler Dim strCustFound As String Public Sub CheckCustId(ByVal CustId As String) _ Implements System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent application code to test the CustId parameter If bolCustOK = True Then 262 Chapter 9 15_57860x ch09.qxd 10/4/05 9:22 PM Page 262 [...]... = New WebControls.WebParts.WebPartVerbCollection(vrbsLanguage) Return vrbs End Get End Property In C#: public override System .Web. UI.WebControls.WebParts.WebPartVerbCollection Verbs { get { WebControls.WebParts.WebPartVerb vrbEnglish = new WebControls.WebParts.WebPartVerb(“EnglishChoice”, “ImplementEnglish”); WebControls.WebParts.WebPartVerb vrbFrench = new WebControls.WebParts.WebPartVerb(“FrenchChoice”,... WebControls.WebParts.WebPartVerb( _ “EnglishChoice”, “ImplementEnglish”) Dim vrbFrench As New WebControls.WebParts.WebPartVerb( _ “FrenchChoice”, “ImplementFrench”) vrbEnglish.Text = “English” vrbFrench.Text = “French” Dim vrbsLanguage(1) As WebControls.WebParts.WebPartVerb vrbsLanguage(0) = vrbFrench vrbsLanguage(1) = vrbEnglish Dim vrbs As WebControls.WebParts.WebPartVerbCollection vrbs = New WebControls.WebParts.WebPartVerbCollection(vrbsLanguage)... WebControls.WebParts.WebPartVerb(“FrenchChoice”, “ImplementFrench”); vrbEnglish.Text = “English”; vrbFrench.Text = “French”; WebControls.WebParts.WebPartVerb [] vrbsLanguage = new WebControls.WebParts.WebPartVerb[2]; vrbsLanguage[0] = vrbFrench; 269 Chapter 9 vrbsLanguage[1] = vrbEnglish; WebControls.WebParts.WebPartVerbCollection vrbs; vrbs = new WebControls.WebParts.WebPartVerbCollection(vrbsLanguage); return vrbs; } } Of course, it’s still necessary... associate it with some clientside event This Visual Basic 2005 code inserts the generated code (after terminating it with a semicolon) and ties it to the onclick event of a button: Dim btn As New Web. UI.WebControls.Button btn.ID = “clb” btn.Text = “Check Customer ID” btn.Attributes.Add(“onclick”, strCodeString & “;”) Me .Controls. Add(btn) In C#: Web. UI.WebControls.Button btn = new Web. UI.WebControls.Button();... a Web Part’s Verb property creates two WebPartVerbs, assigning client-side code as they are created The vrbEnglish WebPartVerb, for instance, is assigned the id “EnglishChoice” and has the client-side routine “ImplementEnglish” set as the verb’s client-side routine: Public Overrides ReadOnly Property Verbs() As _ System .Web. UI.WebControls.WebParts.WebPartVerbCollection Get Dim vrbEnglish As New WebControls.WebParts.WebPartVerb(... ObjectDataSource) Your custom control just has to handle getting the data into the display Much of this work is handled for you when you inherit from the System .Web. UI.WebControls DataBoundControl class, as in this Visual Basic 2005 example: Public Class MyDataBoundControl Inherits System .Web. UI.WebControls.DataBoundControl In C#: class MyDataBoundControl : System .Web. UI.WebControls.DataBoundControl... “ImpEng”,strImplementEnglish, true); } Specialized Controls You can create any custom control that you want And, as discussed at the start of Chapter 3, you can inherit from any existing control and extend it by adding new methods and properties (or by overriding existing methods and properties) However, the NET framework comes with several classes that you can use as a base for creating your own controls In this section,... validated and then checks to see if it is a TextBox If not, the 273 Chapter 9 method throws an HttpException with a message that uses the name of your Validator, as set by the developer If all the tests are successful, the routine returns True: Protected Overrides Function ControlPropertiesValid() As Boolean Dim ctr As System .Web. UI.WebControls.WebControl If Me.ControlToValidate = “” Then Throw New System .Web. HttpException(... string strTestValue = Me.GetControlValidationValue(ctrTestControl); int intValue; if (this.Type == WebControls.ValidationDataType.Integer) 277 Chapter 9 { if (BaseCompareValidator.CanConvert(strTestValue, WebControls.ValidationDataType.Integer) == true) {BaseCompareValidator.Convert(strTestValue, WebControls.ValidationDataType.Integer, out objValue); if (objValue.ToString() == “0”) { return false;... End Sub In C# public class MyControl : Inherits System .Web. UI.WebControls.WebControl, System .Web. UI.ICallbackEventHandler string bolCustFound; void ICallbackEventHandler.RaiseCallbackEvent(string CustId) { application code to test the CustId parameter if (bolCustOK == true) { strCustFound = “true”; } else { strCustFound = “false”; } } At run time, ASP.NET runs the RaiseCallbackEvent subroutine, passing . WebControls.WebParts.WebPartVerb [2] ; vrbsLanguage [0] = vrbFrench; 26 9 Adding Advanced Functionality 15_ 578 60x ch09.qxd 10/ 4 /05 9 :22 PM Page 26 9 vrbsLanguage[1] = vrbEnglish; WebControls.WebParts.WebPartVerbCollection. System .Web. UI.WebControls.WebParts.WebPartVerbCollection Verbs { get { WebControls.WebParts.WebPartVerb vrbEnglish = new WebControls.WebParts.WebPartVerb(“EnglishChoice”, “ImplementEnglish”); WebControls.WebParts.WebPartVerb. Visual Studio 20 05 ensures that the property is set to the name of an existing control with a validation property. However, even 27 2 Chapter 9 15_ 578 60x ch09.qxd 10/ 4 /05 9 :22 PM Page 27 2

Ngày đăng: 06/08/2014, 09:20

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan