Note the tips used in the previous project (if you try again, you will change it at any time)

Source: Internet
Author: User

I believe that you will also use some small technical points in the project, I will launch an attack .................................... ......................

1. js and CSS reference paths

We often use external JS scripts or CSS in projects. I believe everyone will think that there is nothing to say. Just drag CSS into the page ???????

  < Script SRC = " ../Web/JS/public. js " Type = " Text/JavaScript " Language = " Javascript " > </ Script >

 

This operation is correct, but you have never thought about how to change your file path one day (for example, your previous. the path of the ASPX page is (.. /web/UI/default. aspx) and. the JS file path is (.. /web/JS/public. JS)

Now your. the ASPX page path is changed (.. /web/UI/common/default. aspx) can the JS directly referenced by you still work ..........................) no. why ???

Because your src = ".. "indicates you are looking for a higher level, but now you are. there is no JS folder at the UI level on the ASPX page, so the JS script is not introduced, so you need to change it to this

 

 

  < Script SRC = " <% = Geturl ( "" ) %>/Web/JS/public. js " Type = " Text/JavaScript " Language = " Javascript " > </ Script >

 

You can write the following geturl method in the basepage class, as long as the page inherits this class.

///   <Summary>
/// Get a absolute path with applicationpath.
///   </Summary>
///   <Param name = "pageaddress"> Relative page address </Param>
///   <Returns> A absolute path with applicationpath </Returns>
Protected   String Geturl ( String Pageaddress)
{
Return Httpcontext. Current. Request. applicationpath +   " / "   + Pageaddress;
}

 

2. Controls includeCodeThe widget set cannot be modified.

The cause of this error is that similar code is used in

The solution is to put the code in the body.

3. It is often seen that csdn has such a script. As the number of fields entered, textbox also degrades accordingly.

 

 

JS Code
Function textcounter (field, countfield, maxlimit ){
Countfield. Value = Maxlimit - Field. value. length;
If (Field. value. Length > Maxlimit ){
Countfield. style. Color = ' # Ff0000 ' ;
}
}

Function textreset (field, countfield, maxlimit ){
If (Field. value. Length > Maxlimit ){
Alert ( ' The description is too long. the exceeding part will be cut off! ' );
}
Field. Value = Field. value. substring ( 0 , Maxlimit );
Countfield. style. Color = ' #000000 ' ;
Countfield. Value = Maxlimit - Field. value. length;
}
HTML code
  < ASP: textbox runat = " Server " Textmode = " Multiline " ID = " Txtdes "   Class = " Textarea " Rows = " 5 "
Onkeydown = " Textcounter(this.form.txt des, this. Form. count_0, 200 ); " Onblur = " Textreset(this.form.txt des, this. Form. count_0, 200 ); "
Onkeyup = " Textcounter(this.form.txt des, this. Form. count_0, 200 ); " Onchange = " Textcounter(this.form.txt des, this. Form. count_0, 200 ); " > </ ASP: textbox >
< Input type = " Text " Name = " Count_0 "   Readonly Value = " 200 "   />

 

4. Mandatory for Ajax control implementation verification and mandatory

I believe that the above pop-up prompts are mandatory for verification. We all know that the ajaxcontroltoolkit component will be used,

 

< ASP: textbox ID = " Txtname " Runat = " Server "   Class = " Textbox " > </ ASP: textbox >
< ASP: requiredfieldvalidator ID = " Requiredfieldvalidator1 " Controltovalidate = " Txtname "
Runat = " Server " Errormessage = " Employee name cannot be blank " Display = " None " > </ ASP: requiredfieldvalidator >
< Ajx: validatorcalloutextender ID = " Validatorcalloutextender1 " Runat = " Server " Targetcontrolid = " Requiredfieldvalidator1 "
Warningiconimageurl = " ~ /Images/alert-small.gif " Width = " 150px " >
</ Ajx: validatorcalloutextender >

 

 

 

This may happen sometimes. Do you know how to implement it?

In fact, it can also be implemented by validatorcalloutextender in the ajaxcontroltoolkit component, but how can we verify that the pop-up is very simple?

Given when assigning values to dropdownlist

Drplist. Items. Add ( New Listitem ( " Select " , " 0 " ); The value is 0  

 

Therefore, during verification, we can determine whether the verification is greater than 0 based on the selectedvalue value selected by the user.

  < ASP: dropdownlist ID = " Drporglist " Runat = " Server " Cssclass = " Select " >
  </ ASP: dropdownlist >
< ASP: rangevalidator ID = " Rangevalidator1 " Runat = " Server " Display = " None " Minimumvalue = " 1 " // Note that here the minimumvalue value is greater than 0 because the value of... is 0 in my first item.
Maximumvalue = " 10000 "   // Here, you can give 10000 at will. 10000 is enough.
Controltovalidate = " Drporglist " Errormessage = " The organization is required " Type = " Integer " > </ ASP: rangevalidator >

< Ajx: validatorcalloutextender ID = " Validatorcalloutextender7 " Runat = " Server " Targetcontrolid = " Rangevalidator1 "
Warningiconimageurl = " ~ /Images/alert-small.gif " Width = " 150px " >
</ Ajx: validatorcalloutextender >

 

Okay, that's all, A small technical point will be added later ................................. .... everyone's technology is my greatest motivation

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.