|
real time validation --- sounds interesting..
can you given an example.... say with respect to a textbox..
how will you validate them with the different scenario you mentioned("I validate each time the field changes, and validate again before submission, and validate again on the server side. At the same time, I check for script injection, and correct values on the fly, or offer a list of suggestions.")
Thanks
|
|
|
|
|
i use jquery
I bind an event called blur to the textbox, when the user changes fields, the blur is fired, and validates the textbox. I can then format the data, if the value is not correct, then you can paint a red border around the entire area, and change the background color of the textbox.
A red border around the textbox is more visible and non-intrusive than a giant validation message.
A Jquery file designed to work with an update panel. It validate a textbox for an email address. This is one of the designs I use. I have many designs.
$(document).ready(function () {
initiateBinding();
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
});
function EndRequestHandler(sender, args) {
initiateBinding();
}
function initiateBinding() {
$(document).ajaxStart(function () {
});
$(document).ajaxStop(function () {
});
$('[id*="_txt_Email_Jquery_FriendsName_Field"]').blur(function() {
validate_Email();
});
}
function validate_Email() {
var validation_Flag = true;
var txtFocus;
var txtError;
txtFocus = $('[id*="_txt_Jquery_txtFocus"]').val();
txtError = $('[id*="_txt_Jquery_txtError"]').val();
var friendsName_length;
friendsName_length = $('[id*="_txt_Email_Jquery_FriendsName_Field"]').val().length;
if (friendsName_length < 2) {
$('[id*="_txt_Email_Jquery_FriendsName_Field"]').css('background-color', txtFocus).fadeOut("slow");
$('[id*="_txt_Email_Jquery_FriendsName_Field"]').css('background-color', txtError).fadeIn("slow");
$('[id*="_img_Email_Jquery_FriendsName_Error"]').delay(800).fadeIn(300).show("normal");
validation_Flag = false;
}
else if (friendsName_length > 2) {
$('[id*="_txt_Email_Jquery_FriendsName_Field"]').css('background-color', txtError).fadeOut("slow");
$('[id*="_txt_Email_Jquery_FriendsName_Field"]').css('background-color', txtFocus).fadeIn("slow");
$('[id*="_img_Email_Jquery_FriendsName_Error"]').fadeOut(500).hide("normal");
}
var emailAddress_length;
emailAddress_length = $('[id*="_txt_Email_Jquery_EmailAddress_Field"]').val().length;
if (emailAddress_length < 2) {
$('[id*="_txt_Email_Jquery_EmailAddress_Field"]').css('background-color', txtFocus).fadeOut("slow");
$('[id*="_txt_Email_Jquery_EmailAddress_Field"]').css('background-color', txtError).fadeIn("slow");
$('[id*="_img_Email_Jquery_EmailAddress_Error"]').delay(800).fadeIn(300).show("normal");
validation_Flag = false;
}
else if (emailAddress_length > 2) {
$('[id*="_txt_Email_Jquery_EmailAddress_Field"]').css('background-color', txtFocus).fadeIn("slow");
$('[id*="_img_Email_Jquery_EmailAddress_Error"]').fadeOut(500).hide("normal");
var re_EmailAddress = new RegExp("\\w+([-+.']\\w+)*@\\w+([-.]\w+)*\\.\\w+([-.]\\w+)*");
var txt_EmailAddress_Validate = $('[id*="_txt_Email_Jquery_EmailAddress_Field"]').val();
var match_EmailAddress = re_EmailAddress.exec(txt_EmailAddress_Validate);
if (match_EmailAddress == null) {
$('[id*="_txt_Email_Jquery_EmailAddress_Field"]').css('background-color', txtFocus).fadeOut("slow");
$('[id*="_txt_Email_Jquery_EmailAddress_Field"]').css('background-color', "#C6DEFF").fadeIn("slow");
$('[id*="_img_Email_Jquery_EmailAddress_Error"]').delay(800).fadeIn(300).show("normal");
$('[id*="_lbl_Email_Jquery_EmailAddress_Label"]').text("Your format is not valid! (eg. someone@domain.com)").delay(800);
validation_Flag = false;
} else if (match_EmailAddress !== null) {
$('[id*="_txt_Email_Jquery_EmailAddress_Field"]').css('background-color', txtFocus).fadeIn("slow");
$('[id*="_img_Email_Jquery_EmailAddress_Error"]').fadeOut(500).hide("normal");
$('[id*="_lbl_Email_Jquery_EmailAddress_Label"]').text("Enter your friends email address:").delay(500);
}
}
if (validation_Flag == true) {
$('[id*="_txt_Jquery_Approved"]').val("jquery_approved");
}
else {
$('[id*="_txt_Jquery_Approved"]').val("jquery_declined");
}
}
|
|
|
|
|
Thanks jkirkerx. I have no idea about J quey. But this gives me some idea as to what this code intends to do. I will do some research on what you suggested. Probably could incorporate in my project.
Appreciate it.
|
|
|
|
|
All the asp.net validation controls do is load some javascript or microsoft jscript, and run the regex that you assign to it against the textbox value. Then they display some text via javascript, with the text message you assign to it.
Computer users are not that smart, although they think there smart, and the UI (user interface) will become your biggest challenge. Writing a page application is half the battle, the easiest part. The hardest part is validating the form before submission.
If you can't convey the errors to let's say your mom, then the program is partially useless.
|
|
|
|
|
i get error in IE 8 for the code bellow (but it work in IE9)
<script type='text/javascript'>alert('Saved Successfully !')</script><script language='JavaScript'> window.location('../../Personal/View/Default.aspx');</script>
<script type="text/javascript">
the error is :
Message: Object doesn't support this action<br />
Line: 236<br />
Char: 2<br />
Code: 0<br />
URI: http://192.168.0.110:8080/crm/WorkFlows/Forms/WorkReport/default.aspx?md=new&operation=4<br />
thanks in advanced!
modified 14-Aug-12 0:35am.
|
|
|
|
|
Hi,I have Done That!
string url = "../../Personal/View/Default.aspx";
string jScriptValidator = "<script>";
jScriptValidator += "window.open('" + url + "','_self')";
jScriptValidator += " </script>";
page.ClientScript.RegisterStartupScript(typeof(Page), "regJSval", jScriptValidator);
|
|
|
|
|
Error executing child request for new_Page.aspx.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Error executing child request for new_Page.aspx.
Source Error:
Line 14: Server.Transfer("new_Page.aspx");
Above is the error found. It works fine in local host but not when I trying to run in on virtual directory.
When I deleted the Export Excel Function in my page, the error gone.
Microsoft.Office.Interop.Excel.Application xlApp =
new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook xlWorkbook = xlApp.Workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet);
Microsoft.Office.Interop.Excel.Sheets xlSheets = null;
Excel.Worksheet xlWorksheet = null;
Anyone know how to fix this?
|
|
|
|
|
Not sure, are you getting this error: "Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack." ?
|
|
|
|
|
No.
I think it might because of the server doesn't have excel library??
I have no idea how to fix this.
|
|
|
|
|
Member 9169887 wrote: I think it might because of the server doesn't have excel library??
Correct.
Member 9169887 wrote: I have no idea how to fix this.
Install the Excel-interop libraries.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
can you deploy Excel ddl to application path or install Excel InteropServices
-Vijay
|
|
|
|
|
Yes, I can.
I guess the question should rather be "how do I". Answer is on MSDN[^].
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
I have the following table:
<asp:Table runat="server">
<asp:TableRow ID="headerROW">
<asp:TableCell></asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="contentROW">
<asp:TableCell></asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="footerROW">
<asp:TableCell></asp:TableCell>
</asp:TableRow>
</asp:Table>
I want to know how can bring the footerRow to the absolute bottom of the page when the contentROW is less than the page height?
|
|
|
|
|
how to diplay data into a gridview on selecting a value from a dropdownlist.the dropdownlist has set of values.when i select one value,the details based on that value should be displayed in a dropdownlist
M.Sravani
|
|
|
|
|
I am not sure what you expect from such a vague description of your problem. When the index selected changes for your dropdownlist, get the values from where ever you are storing them and then display them in the grid.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
sorry.i got the answer.thank you
|
|
|
|
|
Aoa friendz,i am a beginner in Asp.net.i have been given a task that is how to extrack an image from an email and save it on a disk.so intially help me how to start..how to send an image to an email account in asp.net.i have to use google server i-e my gmail account.
|
|
|
|
|
|
I have a question about what is the best way of setting up session variable(s) in the following situation for a change I am making to a C# web form application.
Currently when the users enter a specfic transaction code that = '123', a property of a textbox is set to visible and the user can enter a comment that is up to 20 characters long. Now the user want to be able to enter a comment that can be up to 15,000 characters.
To accomodate this request, I am going to make a change where the user will be pointed to a new web form page where the user can enter the information. Once the user has entered the information, they will click the save button and will be taken back to the orginal screen they started on.
**Note: A new web form page is going to be generated since there is not enough room on the orginal page to enter the information.
When the user clicks the 'save' button and return to the original web page, I am not going to update the database at that time. I want to pass the transaction id (unique identifier) and the new text field that is up to 15,000 characters back to the original web page as session variable(s). Once the user is on the original web page, I will take the session variable that is up to 15,000 characters and update the database in the same manner the database is currently updated.
Thus can you tell me if using session variables in the case listed abover is a good idea? Why or why not?
Also if there is a better way to accomplish this goal, can you tell me what the better method would be?
|
|
|
|
|
Displaying a new web page just to get an additional field may hinder the user experience. I would suggest that start looking for alternatives like AJAX popups or jQuery popups that dynamically show popups in the same page using visual effects rather than opening new pages. Sharing a field withing the same page is also much easier compared to sharing it between two pages.
|
|
|
|
|
Hi,
I have an asp.net WCF Service, my client application is going to send me excel file as byte array. I have to read those bytes and upload data in the database.
Microsoft Jet, or Ace drivers take the excel file name, is there any way that I can read those excel file bytes directly without storing the file in my file system.
Thanks in advance.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
you make a byte() array for the source, and then copy it to a memorysteam if needed, or just pass the byte array to the destination.
Something like this, I don't something to test it on now
Dim excelFile As byte() = {input}
ByVal excelFile() As Byte
If you need a primitive, that's different.
credit to
[vinz^]
Dim arr As New ArrayList()
arr.Add("AAA")
arr.Add("BBB")
arr.Add("CCC")
Dim byteArray As Byte() = New Byte(2) {}
For i As Integer = 0 To arr.Count - 1
byteArray = DirectCast(arr(i), Byte())
Next
'Read byteArray to stream
Dim stream As New System.IO.MemoryStream(byteArray)
|
|
|
|
|
Hi,
Here I am at the destination side, so I receive excel in byte array format. Then I want to read that array similar to the way we read from excel file using jet or ace drivers.
Is there any way that I can read from a byte array (the byte array created by excel file and I should be able to read the data as if I am reading from an excel file (like row wise and column wise)), actually I am reading from byte array or memorystream created by byte array.
I am able to create memory stream from byte array, but I am unable to read as if I am reading from excel. One more important thing, I dont want to save my file on to the file system, if I save on to file system, I am able to read using oledb jet or ace drivers, but I dont want to save on to the file system.
Is there any way to do that?
I have to update in the database that part I will take care.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
modified 10-Aug-12 19:48pm.
|
|
|
|
|
I thought you just wanted to store the file. Yes You can do that, but i don't how.
Guess you cross that road when you get to it. if your able to store the byte array.
With all do respect, meaning something else
I find it hard to believe that your selling services that you have no clue how to do.
I don't mind helping you, but eventually you need to give something back to CJ, like answer some questions for other OPs, and not be a pure consumer
This reads the dimensions of a flash file from a pure byte stream, just an in insight into what you wish to achieve. I have no interest in reading a excel file, so I'm stopping here at this point. When you ready to ready bytes and translate them into bits, let me know.
Private Function getDimensions(ByVal stream As Stream) As Rectangle
Dim inputStream As Stream = Nothing
Dim signature() As Byte = New Byte(8) {}
Dim rect() As Byte = New Byte(8) {}
stream.Read(signature, 0, 8)
If (System.Text.Encoding.ASCII.GetString(signature, 0, 3) = "CWS") Then
inputStream = New InflaterInputStream(stream)
Else
inputStream = stream
End If
inputStream.Read(rect, 0, 8)
Dim nbits As Integer = rect(0) >> 3
rect(0) = Convert.ToByte(rect(0) And &H7)
Dim bits As String = ByteArrayToBitString(rect)
bits = bits.Remove(0, 5)
Dim dims() As Integer = New Integer(4) {}
For i As Integer = 0 To 3
Dim dest() As Char = New Char(nbits) {}
bits.CopyTo(0, dest, 0, If(bits.Length > nbits, nbits, bits.Length))
bits = bits.Remove(0, If(bits.Length > nbits, nbits, bits.Length))
dims(i) = BitStringToInteger(New String(dest)) / 20
Next
Return New Rectangle(0, 0, dims(1) - dims(0), dims(3) - dims(2))
End Function
Private Function BitStringToInteger(ByVal bits As String) As Integer
Dim converted As Integer = 0
For i As Integer = 0 To bits.Length - 2
converted = (converted << 1) + If(bits(i) = "1", 1, 0)
Next
Return converted
End Function
Private Function ByteArrayToBitString(ByVal byteArray() As Byte) As String
Dim newByteArray() As Byte = New Byte(byteArray.Length) {}
Array.Copy(byteArray, newByteArray, byteArray.Length)
Dim converted As String = ""
For i As Integer = 0 To newByteArray.Length - 1
For j As Integer = 0 To 7
converted += If((newByteArray(i) And &H80) > 0, "1", "0")
newByteArray(i) <<= 1
Next
Next
Return converted
End Function
|
|
|
|
|
I am getting Input string was not in a correct format with the following code:
sql_connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["SQLdb"].ConnectionString);
sql_connection.Open();
sql_command = new MySqlCommand("sp_check_if_member_exist", sql_connection);
sql_command.CommandType = CommandType.StoredProcedure;
sql_command.Parameters.AddWithValue("param_member_id", MySqlDbType.Int32).Value = Convert.ToInt32(Request.QueryString["id"]);
sql_command.Parameters.AddWithValue("param_member_guid", MySqlDbType.VarChar).Value = Convert.ToString(Request.QueryString["guid"]);
sql_command.Parameters.Add("param_is_exist", MySqlDbType.Bit).Direction = ParameterDirection.Output;
sql_reader = sql_command.ExecuteReader();
sql_reader.Read();
if (sql_reader.HasRows)
{
if (Convert.ToBoolean(sql_command.Parameters["param_is_exist"].Value) == true)
{
panelMessage.Visible = false;
panelActivation.Visible = true;
}
else
{
panelActivation.Visible = false;
lblMessage.Text = "Error activating your membership!";
panelMessage.Visible = true;
return;
}
The error occurs on this line:
sql_reader = sql_command.ExecuteReader();
where is my mistake?
|
|
|
|
|