|
Don't know if this will help but why don't you append the operators text in a string builder and set the Session equal to the string builder. Its only one object... so when u read from the session cast the session data to a string builder and read from it.
|
|
|
|
|
Hi MaYo69
but we know session have a limit to store the value in it.
If the user write a more data in text box that could exceed
session limit then in that case we having some error or we
got nothing?Any other option that that?
Do u know HashTable can store the values in it when user navigate
from one page to different like session store the value.
df
|
|
|
|
|
Hi,
I'm not too sure about HashTable. Only thing I used so far is Session, but it's probably cause I never reached the Session limit.
Soz I couldnt help
|
|
|
|
|
Hi
You have to maintain state of page because web applications are stateless. So i would suggest store the info in SQL or any other database before leaving the page. Other way could be viewstate. But you need to take care that view state can slow down the application or site.
I hope this helps you.
Amit
|
|
|
|
|
Hi Amit,
Do you know any other option than that?Can we do it using javascript?
df
|
|
|
|
|
You have to choose from cookies, sessions, viewstate, out proc (SQL), Query string. So i will go for SQL....Long way is also there throgh Java Script ie. Callbacks (behind the scene)...
|
|
|
|
|
hello everyone,
i have a small doubt regarding the validation.I have a textbox in an .aspx form i want to write a validation through C# code such that the textbox should accept only integers but not using validation controls.Plz hellp me in solving this problem
regards,
murali
murali
|
|
|
|
|
Go for java script.
function IsNumeric(sText)
{
var ValidChars = "0123456789";
var IsNumber=true;
var Char;
var NumberofDots=0;
for (i = 0; i < sText.length && IsNumber == true; i++)
{
Char = sText.charAt(i);
if (ValidChars.indexOf(Char) == -1)
{
IsNumber = false;
}
} // end of for loop
return IsNumber;
} // End of IsNumeric function
Amit
|
|
|
|
|
|
Hi Forum,
I am having some really iritating problems with an simple input page which should pass parameters into a stored procedure from the text boxes first and last name.
I keep getting the error during exection of sp_myinsert, pfirstname not defined, every time i try to submit the form
Has anyone got any suggestions I have giving my code for procedure and page
many thanks
boy
--------------------------------
CREATE DEFINER=``@`localhost` PROCEDURE `sp_myInsert`(pFirstName varchar(20), pLastName varchar(30))
BEGIN
INSERT INTO Names (FirstName, LastName) values (pFirstName, pLastName);
END
-------------------------------------------
<%@ Page Language="VB" debug="true" %>
<%@ Import Namespace = "System.Data" %>
<%@ Import Namespace = "MySql.Data.MySqlClient" %>
<script language="VB" runat="server">
Sub page_load()
End Sub
''' <summary>
''' Page_load
''' Recognised by ASP and must be provided on loading of page.
'''
''' Creates connection to database, passes stored procedure into test database
''' and fills a table, which is showing in web browser
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Sub sendData(ByVal sender As Object, ByVal e As EventArgs)
Dim litErr As New LiteralControl
'Create connection string to pass database, string holds login information to mySQL,
Dim connectionString As String
connectionString = "Server=; uid=; pwd=;database=test;"
'Builds .net mysql connection and passes connection string into method
Dim connection As New MySqlConnection(connectionString)
'Open connection to DB
connection.Open()
'Create mySql command string for passing query or SPROC(Stored Procedure)
Dim cmdString As New MySqlCommand
'Set Command to equal mySql connection,t so can pass SQL query
cmdString.Connection = connection
Try
'Set command string to equal SPROC
cmdString.CommandText = "sp_myinsert"
'ONLY PLACE THIS IF SPROC, sets the command to a SPROC
cmdString.CommandType = CommandType.StoredProcedure
Dim param As New MySqlParameter
param = cmdString.Parameters.Add("p_firstname", MySqlDbType.VarChar)
param.Direction = ParameterDirection.Input
param.Value = txtFirstName.Text
param = cmdString.Parameters.Add("p_lastname", MySqlDbType.VarChar)
param.Direction = ParameterDirection.Input
param.Value = txtLastName.Text
cmdString.ExecuteNonQuery()
connection.Close()
Catch ex As Exception
litErr.Text = ex.Message
MsgBox(ex.Message)
End Try
End Sub
</script>
<!DOCTYPE html PUBLIC
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script language="vbscript" type="text/vbscript">
</script>
</head>
<body>
<form id="form1" runat="server">
ENTER FIRSTNAME<asp:TextBox runat="server" ID="txtFirstName">
</asp:TextBox><br /><br />
ENTER LAST NAME
<asp:TextBox runat="server" ID="txtLastName"></asp:TextBox>
<asp:Button runat="server" ID="submit" Text="Submit" onclick="sendData" />
</form>
</body>
</html>
|
|
|
|
|
Hi all,
I want to export reports in my database to snapshot viewer files.
Access.ApplicationClass app = new Access.ApplicationClass();<br />
app.AutomationSecurity = 1;<br />
app.OpenCurrentDatabase( "c:\\data\\Copy of ITS2005.mdb", false, "" );<br />
app.DoCmd.OutputTo( Access.AcOutputObjectType.acOutputReport, "Licenced Fabricators", "Snapshot Format (*.snp)", "c:\\OMFS.snp", Type.Missing, Type.Missing, Type.Missing);<br />
app.DoCmd.Quit( Access.AcQuitOption.acQuitSaveNone );
This works perfectally fine in a windows form but the OpenCurrentDatabase just doesnt want to finish executing in ASP.NET Page.
Any help would be appreciated!
André.
|
|
|
|
|
sorry but i dnt know if my answer will help u by any way or not. but i done xls report of database in my site. here is what i done earlier . there are two ways..
(but at final i used dataset and manually write .. to Responce. which is working fine and is Live)-----
#region old code
//Response.Clear();
//Response.Buffer= true;
//Response.ContentType ="application/vnd.ms-excel";
//Response.Charset = "";
//this.EnableViewState = false;
//System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
//System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
//this.ClearControls(Dgreport);
//Dgreport.RenderControl(oHtmlTextWriter);
//Response.Write(oStringWriter.ToString());
//Response.End();
#endregion
----------------------------------------------------
//try
//{
#region old code diff way
/*DataSet tempds2=new DataSet();
tempds2=getReportData();
if(!(tempds2.Tables[0].Rows.Count<=0))
{
string fileName = "Report.xls";
string FullPath = Server.MapPath("\\")+fileName;
tempds2.WriteXml(FullPath,XmlWriteMode.WriteSchema );
FileInfo file=new FileInfo(FullPath);
if(file.Exists)
{
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/vnd.ms-excel";//"application/octet-stream";
Response.WriteFile(file.FullName);
}
}*/
#endregion
pallavi
|
|
|
|
|
Thanx for the reply,
Some questions, what exactly does this getReportData() method do and is it a custom method??
If your solution worked for u, can u perhaps supply he with a solution or code file plz?
Otherwise dont you know of another way to export reports
|
|
|
|
|
ya both the methods i given worked for me. the getReportData() is custom function wich return me dataset. and first method is useful if u want to export data u are seeing in datagrid (paging =true). but i moved to second because i wanted to export the whole dataset to xls not the page in datagrid.
the third method i am using is not logical but works perfect for my clients requirement. take the data from database in dataset and simple generate the xls using . on 'export to excel' button click with javascript i open blank web form where on page load i write following code. u can pass dataset to this page or get datadet on this pageload.
i hope u will get the useful from below--
Response.Clear();
Response.Buffer= true;
StringBuilder responce_=new StringBuilder();
StringBuilder header=new StringBuilder();
header.Append(""+
"");
header.Append("");
header.Append("");
header.Append("");
header.Append("");
header.Append("");
header.Append("");
header.Append("");
header.Append("");
header.Append("");
header.Append("");
header.Append("");
if(!(tempds2.Tables[0].Rows.Count<=0))
{
for(int i=0;i<tempds2.tables[0].rows.count;i++)
{
responce_.append("<tr>");
for(int j=0;j<tempds2.tables[0].columns.count-1;j++)
{
if(j==0 )
{
responce_.append("<td="" width="70" align="center">"+tempds2.Tables[0].Rows[i].ItemArray[j].ToString()+"");
}
else if(j==1 || j==2 )
{
responce_.Append("");
}
else if(j==3)
{
responce_.Append("");
}
else
{
responce_.Append("");
}
}
responce_.Append("");
}
}
responce_.Append("");
responce_.Append(""+
""+
" | | | | "+
" | | | | " +
"Customer Details Report "+ " | Customer ID | Customer Name | Address | City | Country | Phone Number | Mobile Number | Fax Number | Email | Entry Date | "+tempds2.Tables[0].Rows[i].ItemArray[j].ToString()+" | "+tempds2.Tables[0].Rows[i].ItemArray[j].ToString()+" | "+tempds2.Tables[0].Rows[i].ItemArray[j].ToString()+" | " +tempds2.Tables[0].Rows.Count+ " Records Found. "+ " | ");
Response.ContentType = "application/vnd.ms-excel";
Response.Write(header.ToString()+responce_.ToString());
Response.Charset="";
Response.End();
dnt forget to write last statement.
---
-- modified at 7:55 Wednesday 27th June, 2007
pallavi
|
|
|
|
|
Hi,
Thanks alot for your reply, this seems to be exactly what I am looking for!! I also think the second method is whit seems to be appropriate in this situation.
|
|
|
|
|
welcome..
pallavi
|
|
|
|
|
Hi,
Soz to bother u again but you never told me what it is the getReportData does. I assume it gets the report using OLE, but how does one do that????
|
|
|
|
|
I want to enter data for the txtbox where it has to check some conditions like the first character. I had written the following code, but it is not working, can anyone tell what is the error?
If (Mid(Txtpno.Text, 1,1) <> "P") Or (Mid(Txtpno.Text, 1, 3) <> "oth" Or (Mid(Txtpno.Text, 1, 2) <> "PT") Or (Mid(Txtpno.Text, 1, 2) <> "st") Or (Mid(Txtpno.Text, 1, 2) <> "ac") Or (Mid(Txtpno.Text, 1, 2) <> "vl") Or (Mid(Txtpno.Text, 1, 2) <> "aP") Or (Mid(Txtpno.Text, 1, 2) <> "Tc")) Then
Lblmsg.Visible = True
Lblmsg.ForeColor = Drawing.Color.Red
Lblmsg.Text = "Invalid Pno!"
Exit Sub
End If
|
|
|
|
|
Hi
Firstly i would recommend moving the logic out of the form and into a class which could be used thoughout your application ensuring that the same business rule is followed consistently.
For readability i would also suggest working through as single rules which would then ensure that less processing would take place as the whole statement need not be parsed and the function would return as soon as an invalid pNo rule was reached.
Public Function ValidatePNo(ByVal pNo as string) as boolean
If pNo.startswith("p") then return false
if pNo.startswith("oth") then return false
..
Return True
End Function
|
|
|
|
|
Thank you. It is working.
Chaitra N
|
|
|
|
|
You've used "<>" together with "or". Be very careful.
Consider the following:
If (Mid(Txtpno.Text, 1,1) <> "P") or (Mid(Txtpno.Text, 1,1) <> "F") then
end if
What you're actually saying is that if the first letter doesn't equal P or the first letter doesn't equal F then do something.
What fulfills the criteria of not having a first letter equal to P or not having a first letter equal to F? Absolutely everything is the answer.
If you're trying to do what I think you're trying to do, then you want to use 'and' operators instead of 'or'. It is however exceedingly messy and confusing and you'd be much better off abstracting it into a separate function that checks validity against each parameter one by one.
|
|
|
|
|
I need to sort my datagrid,when user clicks any columnheader ,datagrid should be sorted on that column, I m using sortexpression and datagrid_sortcommand but don't know how to handel datagrid and e.sortexpression in datagrid_SortCommand method.
Plz guide me.
With Thanks & Regards
Amit Sk Sharma
|
|
|
|
|
See that have u made datagrid allow sorting property to true.
df
|
|
|
|
|
Hi,
I am using IFrame in my project (which I know some people might say frames are evil but I just don't know what best to replace it).
Let say FrameLeft and FrameRight, FrameLeft is a navigation area which will cause FrameRight to switch from one page to another. The problem is when I am not at my main page and I click Refresh button, it refresh and bring me back to my main page.
I found a way in HTML that it will refresh the same page last time but unfortunately due to hardware failure, I lost the codes.
So I really appreciate if anyone has any idea for this.
Thanks in advance.
J Liang
|
|
|
|
|
I would suggest moving away from IFrames and using DIV elements to layout your page. You can achieve the same look without all of the problems which the IFrames have caused.
A site called CSSPlay has a section on layouts which show some example page layouts and the relevent CSS and HTML needed to achieve the result
http://www.cssplay.co.uk/layouts/[^]
|
|
|
|