7-26 xmltextreader, xmltextwriter & Web Service

Source: Internet
Author: User
Tags md5 encryption

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 ();
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.