Dynamically hide text under ASP. NET development

Source: Internet
Author: User

Recently, I am engaged in a software project internship for such a big job. The goal is to build a hospitalization information management system. We chose ASP. NET technology, that is, to complete system development in collaboration with vs2008 and SQL Server. I encountered many problems in the development process, but I also learned a lot. The following describes how to dynamically hide text.

This technology can be viewed at http://www.bianchengla.com/bbs?, as shown below:

1. Add the following code to the ASPX page: (here I use the template page technology and usually put it in the head)

<Asp: Content ID = "head" runat = "server" contentplaceholderid = "head">
<Script language = "JavaScript" type = "text/JavaScript">
VaR Col = new array ();
Col [15] = '# ff0000 ′;
Col [14] = '# ff1111 ′;
Col [13] = '# ff2222 ′;
Col [12] = '# ff333333 ′;
Col [11] = '# ff4444 ′;
Col [10] = '# ff5555 ′;
Col [9] = '# ff6666 ′;
Col [8] = '# ff777777 ′;
Col [7] = '# ff8888 ′;
Col [6] = '# ff9999 ′;
Col [5] = '# ffaaa ';
Col [4] = '# ffbbbb ';
Col [3] = '# ffcccc ';
Col [2] = '# ffddd ';
Col [1] = '# ffeeee ';
Col [0] = '# ffff ';
VaR I = col. length;
Function over (FLAG)
{
If (flag = 1) {I = col. length; TD. style. Color = '# ff0000 ′;}
If (I> = 0) {I-; TD. style. Color = Col [I];}
SetTimeout ('over (0) ', 300); // gradient
}
</SCRIPT>
</ASP: content>

2. Apply for a div space placement prompt on the form

<Div id = "TD"> <asp: label id = "lblmessage" runat = "server" font-names = "" font-size = "medium"> </ASP: Label> </div>

3. Add the following code to the corresponding CS file on the page:

// Color change
Protected void MessageBox (string text)
{
Lblmessage. Text = text;
Page. clientscript. registerstartupscript (clientscript. GetType (), "myscript1", "<SCRIPT> over (1) </SCRIPT> ");
}

4. In this case, you only need to call this function under the function to be used in the CS file: (for example, the function submitted to the database here)

// Submit to database
Protected void btnsubmit_click (Object sender, eventargs E)
{

Try
{
String year = datetime. Now. year. tostring ();
String month = datetime. Now. Month. tostring ();
String day = datetime. Now. Day. tostring ();
If (convert. toint32 (month) <10)
{
Month = "0" + month;
}

If (convert. toint32 (day) <10)
{
Day = "0" + Day;
}
String time = year + "/" + month + "/" + Day;
String temperature = txtpatient_temp.text.trim ();
String pluse = txtpatient_pluse.text.trim ();
String Pressure = txtpatient_pressure.text.trim ();
String Height = txtpatient_height.text.trim ();
String Weight = txtpatient_weight.text.trim ();
If (temperature = "")
{
Temperature = "0 ″;
}
If (pluse = "")
Pluse = "0 ″;
If (pressure = "")
Pressure = "0 ″;
If (Height = "")
Height = "0 ″;
If (Weight = "")
Weight = "0 ″;
Dataaccess. sqlcmd = "insert into State (patient_id, user_id, patient_temp, patient_pressure, values, patient_height, values, doing_date, nurse_remark, doing_state) values ('" + values + "', '"+ dataaccess. muser_id + "','" + convert. todouble (temperature) + "','" + convert. todouble (pressure) + "','" + convert. todouble (pluse) + "','" + convert. todouble (height) + "','" + convert. todouble (weight) + "','" + time + "','" + txtnurse_remark.text.trim () + "', 1 )";
Dataaccess. sqldc ();

MessageBox ("submitted successfully ");
Clear ();
}
Catch
{
MessageBox ("data submission failed ");
}

}

The final result is as follows:

As you can see, this function is basically implemented. However, if your page is not white, you can modify it in the Java Script code and change the color value. Try it by yourself.

Thank you for your technical support.

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.