1 xmltextreader, xmltextwriter
Using system;
Using system. collections;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. Web;
Using system. Web. sessionstate;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. htmlcontrols;
Using system. xml;
Namespace xmltextreaderwriter
...{
/** // <Summary>
/// Summary of webform1.
/// </Summary>
Public class webform1: system. Web. UI. Page
...{
Protected system. Web. UI. webcontrols. Button btntest;
Protected system. Web. UI. webcontrols. Label LBL;
Private void page_load (Object sender, system. eventargs E)
...{
// Place user code here to initialize the page
}
Code generated by web form designer # code generated by region web Form Designer
Override protected void oninit (eventargs E)
...{
//
// Codegen: This call is required by the ASP. NET web form designer.
//
Initializecomponent ();
Base. oninit (E );
}
/** // <Summary>
/// The designer supports the required methods-do not use the code editor to modify
/// Content of this method.
/// </Summary>
Private void initializecomponent ()
...{
This. btntest. Click + = new system. eventhandler (this. btntest_click );
This. Load + = new system. eventhandler (this. page_load );
}
# Endregion
Private void btntest_click (Object sender, system. eventargs E)
...{
Xmltextreader reader = new xmltextreader (server. mappath ("Web. config "));
String S = "";
While (reader. Read ())
...{
S + = reader. nodetype + ":" + reader. Value + "<br> ";
}
LBL. Text = s;
Reader. Close ();
Xmltextwriter write = new xmltextwriter (server. mappath ("test. xml"), system. Text. encoding. utf8 );
Write. writestartelement ("AA ");
Write. writestartelement ("BB ");
Write. writestring ("cc ");
Write. writeendelement ();
Write. writeendelement ();
Write. Close ();
}
}
}
2. MD5 encryption for Web Services
Using system. Web. Security;
[Webmethod]
Public String hashbymd5 (string Str)
{
Return formsauthentication. hashpasswordforstoringinconfigfile (STR, "MD5 ");
}
3. Return an example of selecting a unit price greater than the unit price of a dataset.
[Webmethod]
Public String helloworld (string name)
{
Return name + ", hello ";
}
[Webmethod]
Public dataset getproducts ()
{
Da. Fill (Ds. products );
Return Ds;
}
Private void btntest_click (Object sender, system. eventargs E)
{
Myservice service = new myservice ();
LBL. Text = service. helloworld ("Mike ");
}
Private void btnsearch_click (Object sender, system. eventargs E)
{
Myservice service = new myservice ();
Dataset DS = service. getproducts ();
Dataview DV = Ds. Tables [0]. defaultview;
DV. rowfilter = "unitprice>" + txtprice. text;
This. DGD. datasource = DV;
This. DGD. databind ();
}