. NET some of the notes, to record their own

Source: Internet
Author: User
Tags httpcontext strtok

<%: Html.label ("Document name:")%>
Indicates that the label control is associated with this input, and this control is triggered when the label is clicked <input type= "text" name= "Socsecnum" id= "document name:"/>

It's free now.
Xianzaikongxian

The fewest orders received
Jiedanzhuishao

The most frequently repaired
Weixiucishu

The shortest repair time
Shijianzuidaun

The youngest
Nianlingzuixiao

and repeat, from top to bottom.

Updatemode= "Conditional" childrenastriggers= "false"


<%
if (detil!=null&&detil.rows.count!=0)
{
for (Var n=0;n<detil.rows.count;n++)
{%>
document.getElementById ("List"). innerhtml+= ' <li> ' + ' <% =detil.rows[n][' Name ']%> ' + ' </li> ';
<%
if (detilchild!=null&&detilchild.rows.count!=0)
{
for (Var p=0;p<detilchild.rows.count;p++)
{%>
document.getElementById ("List"). innerhtml+= ' <li> ' + ' <% =detilchild.rows[p][' Name ']%> ' + ' </li> ';
<%}
}%>
<%}
}%>


<%
if (detil! = NULL && Detil.Rows.Count! = 0)
{
for (int i = 0; i < Detil.Rows.Count; i++)
{%>
<li id= "KKK" ><strong><%=detil.rows[i]["Name"]%></strong></li>
<%}
}%>

Table==null just judge whether there is no instantiation, and can not be used as the basis for the empty table, to use table.rows.count>0.


MFC patchwork SQL statement methods
Sql_insert. Format (_t ("INSERT into UserInfo (name) values (\ '%s\ ');"), name);
std::string s= CStringA (Sql_insert);
const char *ch = S.C_STR ();

MFC gets other page control methods
cmcfstudentdlg* pWnd = (cmcfstudentdlg*) GetParent ();
CListCtrl *plist= (CListCtrl *) Pwnd->getdlgitem (IDC_LIST1);
UpdateData (TRUE);


Traverse Map
Map<cstring,sockaddr_in>::iterator it;
it = Person.begin ();
while (It! = Person.end ())
{
it + +;
M_combo. AddString (It->first);
}


Split string
int main (void)
{
Char str[] = "2015-3-22,abcd,efg,hij,klmn,opq,rst,uvw,xyz,tao";/* The original string to be delimited */
Char seg[] = ","; /* Delimiter here is a comma comma, delimiter can be specified for you, such as semicolon, space, etc. */
Char charlist[50][50]={""};/* specifies the location where the substring is stored, defining a two-dimensional array of strings */
int i = 0;
Char *substr= strtok (str, SEG);/* Use out-of-the-box segmentation functions, substr to split substrings */

while (substr! = NULL) {
strcpy (CHARLIST[I],SUBSTR);/* Copy the newly split substring substr to the charlsit you want to store */
i++;
printf ("%s\n", substr);
substr = Strtok (NULL,SEG);/* At the first call, Strtok () must give the parameter str string,
The subsequent call sets the parameter str to NULL. Each successful call returns a pointer to the fragment being split. */
}
GetChar ();/*press enter key to continue*/
return 0;
}


constructor function:
The function name is the same as the class name, and the constructor is used to initialize the parameters directly by default when calling the class, even if the constructor is not written, the system will default to you a constructor (there are virtual members in the class, there are constructors for the base class in the class, static members have constructors)


When constructing a class, if the passed in parameter is the same as the parameter name of the argument in the class, the parameter in the specified class is used This->x


C + + can accept multiple inheritance
Class A:public B,public c{}

Virtual functions
virtual void Breath ()
{ }
C + + at compile time does not bind breath, will be called at the time of the specific call that method, if not declared, will be at compile time binding method. Add virtual to C + + to implement polymorphism, add virtual to the base class method, override the function in the derived class, and the runtime will invoke the appropriate method based on the actual type of the object.


Pure virtual function
virtual void Breathe () =0
The method is not implemented, just a declaration. When a derived class inherits, it is necessary to implement a pure virtual function, otherwise the derived class can only be used as an abstract class and cannot be instantiated


Overwrite and hide
Overwrite: function name is same, parameter is same, function is virtual function. When you create an instance object, you bind the virtual function to a function in the Power class
Hidden: A function is not a virtual function and is hidden as long as the function name is the same or the parameter is the same. To implement a hidden function base class name in a derived class:: Function name (parameter)
Overloads of a function occur in the same class.


int a=3;
int &b=a;
int c=5;
B=c;
At this point A and B values are 5, and A's value represents the value of B.
int a=3;
int *b=&a;
At this point B is the storage address of a, that is, the pointer, and then change the value of B is to change the value of the pointer, a value will not change.


Resolve header file Duplicate definition
Add the following statement in the Animal.h
#ifndef Animal_h_h
#define Animal_h_h

static sockaddr_in addrsrv = Person[strcbtext];

HWND hwnd = (HWND) FindWindow (NULL, window name);//Get window handle based on window name caption
c***dialog* pwnd= (c***dialog*) c***dialog::fromhandle (hWnd); Object pointer to get dialog box by handle
Pwnd->xxx (); Call C***dialog in the function xxx ();
HWND hwnd = Pwnd->getsafehwnd (); Gets the handle to the control


Edit Control
Get pointer
Pboxone = (cedit*) GetDlgItem (IDC_EDIT1);
Assign value
Pboxone-> SetWindowText (_t ("FOO"));
Take value
pboxone-> GetWindowText (str);


C + + global variables
The. h file adds
extern CString Tomessage;
The. cpp file adds
CString Strcbtext;
Other file references under the same item are added
. h files and extern CString strcbtext; declaring variables

Pop-up Box search modification
<script type= "Text/javascript" src= "Js/jquery.min.js" ></script>
<script type= "Text/javascript" src= "Js/bootstrap.js" ></script>
function Search () {
var texts = document.getElementById ("Pho"). Value;
var company = "{' Phoid ': '" + Texts + "'}";
$.ajax ({
Async:false,
Type: "Post",
URL: "Taskmanagementadd.aspx/search",
Data:company,
ContentType: "Application/json;charset=utf-8",
DataType: "JSON",
Success:function e (msg) {
var mytab = document.getElementById ("table");
var rowNum = mytab.rows.length;

for (var i = 1; i < RowNum; i++) {
Mytab.deleterow (i);
RowNum = rowNum-1;
i = i-1;
}
var word = Msg.d.split (";");
if (Msg.d.split (","). Length > 2) {
for (var tt = 0; TT < word.length; tt++) {
var words = Word[tt].split (",");
var tabrow = Mytab.insertrow (TT + 1);
Tabrow.setattribute ("Style", "text-align:center");
Tabrow.insertcell (0). InnerHTML = ' <tr style= ' text-align:center ' ><td><input id= ' ' + words[2 ' + ' name= ' U Ser "type=" Radio "/></td>";
Tabrow.insertcell (1). InnerHTML = ' <td > ' + words[0] + ' </td> ';
Tabrow.insertcell (2). InnerHTML = ' <td > ' + words[1] + ' </td> ';
}
}
else {
var words = Msg.d.split (",");
var tabrow = Mytab.insertrow (1);
Tabrow.setattribute ("Style", "text-align:center");
Tabrow.insertcell (0). InnerHTML = ' <td><input id= "' + words[2] + '" name= "User" type= "Radio"/></td> ";
Tabrow.insertcell (1). InnerHTML = ' <td > ' + words[0] + ' </td> ';
Tabrow.insertcell (2). InnerHTML = ' <td > ' + words[1] + ' </td> </tr> ';
}
mytab.rows[0].cells[0].innerhtml = MSG.D;
},
Error:function (XHR) {alert (' page error \ n ' + xhr.responsetext);}
});
}

Gets the value of the popup box selected
function sub () {
var s = ';
var obj = document.getelementsbyname (' User ');
for (var i = 0; i < obj.length; i++) {
if (obj[i].checked)
{s = obj[i].id;}
}
var Name = $ ("#" + s). Parent (). Next (). text ();
var Phone = $ ("#" + s). Parent (). Next (). Next (). text ();
document.getElementById ("TUser"). Value = Name;
}

JS Gets the selected value of the Select tag
var obj = document.getelementbyidx_x ("Testselect"); Location ID
var index = Obj.selectedindex; Check Index
var text = Obj.options[index].text; Select text
var value = Obj.options[index].value; Checked values
Get selected Select value in jquery

The first way
$ (' #testSelect option:selected '). text ();//Selected texts
$ (' #testSelect option:selected '). Val ();//Selected value
$ ("#testSelect"). Get (0). selectedindex;//Index

The second way
$ ("#tesetSelect"). Find ("option:selected"). Text ();//Selected
.... val ();
..... get (0). SelectedIndex;

Pop-up box is not useful
Scriptmanager.registerstartupscript (this, this.) GetType (), "", "alert (' Insufficient account balance ');", true);
Hide an element in the background
Scriptmanager.registerstartupscript (this, this.) GetType (), "", "$ (function () {$ (\". qbm-notice\ "). css (\" display\ ", \" None\ ");})", true);


The database does not recognize Chinese characters, and when setting up the connection string, add: Charset=utf8


How to use objects such as ASP. Request,server in your custom class:
namespace (you may need to add a reference to the project before referencing it in the class)
Using System.Web.SessionState;
httpcontext.current.session["Totalpage"]. ToString ();
httpcontext.current.request.querystring["CID"]. ToString ();


Use of Ajax


The interface must refer to Jquery.min.js
<script type= "Text/javascript" >
function Sub () {
$ (document). Click (function (e) {
var name=$ (E.target). Parent (). Prev (). Prev (). Prev (). Prev (). Prev (). Prev (). Prev (). text ();
var p = $ (e.target). attr ("id");
var p = ' U ';
var params = ' {IP: ' ' + P + ' "} ';
var params = ' {name1: ' + name + ', phone1: ' + Phone + ' '} ';
$.ajax ({
Type: "Post",
URL: "Phone.aspx/submit",
Data:params,
ContentType: "Application/json;charset=utf-8",
DataType: "JSON",
Success:function E () {
Shanchu.remove ();
Alert ("Operation succeeded! ");
},
Error:function () {alert ("Llll");}
});
// })
}
</script>

The values returned by the background are split
Success:function e (msg) {
var Name = document.getElementById ("Stuname");
var STRs = Msg.d.split (";"); Character segmentation
for (var i = 0; i < strs.length; i++) {
if (strs[i]! = "") {
name.innerhtml + = ' <li class=\ "Flex bd-lis\" ><section class=\ "Iconfont icon-yuanxingweixuanzhong bd-a\" > </section><section class=\ "bd-b\" ></section><section class=\ "bd-c\" > ' + strs[i].toString () + ' </section><section class=\ ' bd-d iconfont icon-xiangyou1\ ' ></section></li> ';
}
}
},
Error:function () {alert ("Llll");}

Background


[System.Web.Services.WebMethod ()]
public static void Submit (String IP)
{

}


Gets the ID of the current click event element:
$ (". BL"). Click (function (e) {
Window.location.href = "noticedetil.aspx?id=" + $ (This). attr ("ID");
})

Pre-load Modify page

$ (function () {
var detile= ' <%=NoticeDeilStr%> ';
var STRs = Detile.split (";");
$ ("#NoticeType"). Append (Strs[0]);
$ ("#NoticeTitle"). html (strs[1]);
$ ("#StartTime"). html (strs[2]);
$ ("#OverTime"). html (strs[3]);
$ ("#StopTime"). html (strs[4]);
$ ("#NoticeContent"). html (strs[5]);
})

When you need information for more than one table, you don't have to make multiple queries, and you can put the data together using left-right or inner joins.
Select T1.id,t2.id as pp,t1.phone as TT from ((SELECT * from ' user ' where id= ' ee ') t1 the left JOIN (SELECT * from ' user ' wher E Roleid = ' 1 ') t2 on T1.classid=t2.classid)


Pass the Click object:

Onclick= "Sub (This)"

Receive: function Sub (obj) {
var p = $ (obj). Prev (). attr ("id");
}

Ajax button Jump, you can only use the Button property, do not use the submit

The Cookies in C #


Set up
HttpCookie cookie = new HttpCookie ("CookieName");
Cookies. Value = "Name1"
HTTPCONTEXT.CURRENT.RESPONSE.COOKIES.ADD (cookie);
HttpContext.Current.Response.AppendCookie (cookie);
Read
httpcontext.current.request.cookies["CookieName"]. Value
Judging existence
if (httpcontext.current.request.cookies["CookieName"]==null) {
Do something
}
Validity
Cookies. Expires = DateTime.Now.AddDays (1);


Get DropDownList selected value
Ddlbranch.selectedvalue;
Get DropDownList selected text
DdlCurrentDegree.SelectedItem.Text;

<system.data>
<DbProviderFactories>
<add name= "MySQL data Provider" invariant= "MySql.Data.MySqlClient" description= ". Net Framework Data Provider for MySQL "Type=" MySql.Data.MySqlClient.MySqlClientFactory, Mysql.data, version=6.9.9.0, Culture=neutral, Publickeytoken=c5687fc88969c44d "/>
</DbProviderFactories>
</system.data>

Get XML node value
XmlDocument xmldoc = new XmlDocument ();
XmlDoc. LOADXML (Jsontext);
Get node List
XmlNodeList topm = xmldoc. ChildNodes;
foreach (XmlElement element in topm)
{
id = element. getElementsByTagName ("prepay_id") [0]. InnerText;
sig = element. getElementsByTagName ("sign") [0]. InnerText;
Nonce_str = element. getElementsByTagName ("Nonce_str") [0]. InnerText;
}


Prevent triggering of parent element click events in child elements

Event.stoppropagation (); Block events from bubbling


Show Full Screen
Html:

<div class= "Over" ></div><!--background Layer--
<div class= "logoimg amplifyimg" ><!--Note: The amlifyimg here is not limited---

</div>


Css:
. over {position:fixed; left:0; top:0; width:100%; z-index:100;}
. tempcontainer {position:fixed; width:100%; margin-right:0px; margin-left:0px; text-align:center; z-index:101;}


Js:
var imgsobj = $ ('. amplifyimg img ');//images that need to be enlarged
if (imgsobj) {
$.each (Imgsobj,function () {
$ (this). Click (function () {
var currimg = $ (this);
Coverlayer (1);
var Tempcontainer = $ (' <div class= "Tempcontainer" ></div> ");//Picture container
The WITH (Tempcontainer) {//width method is equivalent to $ (this)
AppendTo ("body");
var windowwidth=$ (window). width ();
var windowheight=$ (window). Height ();
Get image original width, height
var orignimg = new Image ();
Orignimg.src =currimg.attr ("src");
var currimgwidth= orignimg.width;
var currimgheight = orignimg.height;
if (currimgwidth<windowwidth) {//In order to make the picture not distorted, when the picture width is small, retain the original image
if (currimgheight<windowheight) {
var topheight= (windowheight-currimgheight)/2;
if (topheight>35) {/* Here in order to center the picture height on the entire phone screen: because there will be a title navigation in Android,ios, 35 is the height of the title navigation */
topheight=topheight-35;
CSS (' top ', topheight);
}else{
CSS (' top ', 0);
}
HTML (' ');
}else{
CSS (' top ', 0);
HTML (' ');
}
}else{
var currimgchangeheight= (currimgheight*windowwidth)/currimgwidth;
if (currimgchangeheight<windowheight) {
var topheight= (windowheight-currimgchangeheight)/2;
if (topheight>35) {
topheight=topheight-35;
CSS (' top ', topheight);
}else{
CSS (' top ', 0);
}
HTML (' ');
}else{
CSS (' top ', 0);
HTML (' ');
}
}
}
Tempcontainer.click (function () {
$ (this). Remove ();
Coverlayer (0);
});
});
});
}
else{
return false;
}
Using the Disable mask effect
function Coverlayer (tag) {
With ($ (') ') {
if (tag==1) {
CSS (' height ', $ (document). Height ());
CSS (' Display ', ' block ');
CSS (' opacity ', 1);
CSS ("Background-color", "#191919");
}
else{
CSS (' Display ', ' none ');
}
}
}

Write to Foreground JS

StringBuilder sb = new StringBuilder ();
Sb. Append ("<script src=\" js/jquery-weui.js\ "></script>;");
Clientscript.registerstartupscript (this. GetType (), "Loadpicscript", sb. ToString ());


Apple returns without reloading JS


<input type= "hidden" id= "refreshed" value= "no" >


if ((/iphone|ipod|ipad.*os 5/gi). Test (navigator.appversion)) {

Window.onpageshow = function (event) {

if (event.persisted) {

Window.location.reload ()

}

};

} else {

onload = function () {

var refreshedid = document.getElementById ("refreshed");

if (Refreshedid.value = = "No") {

Refreshedid.value = "Yes";

} else {

Refreshedid.value = "No";

Location.reload ();

}

}

}

Server control add Foreground JS event


BUTTON1.ATTRIBUTES.ADD ("OnClick", "Return Load ()");
function returns True to continue the background click event
function returns false only the foreground JS event is executed

. NET some of the notes, to record their own

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.