|
tanks for your replies,
i am confused because i am very new in asp.net applications . the point of i couldnt understand why this code runs body onload event but returns error on button click event . when i click the button i will start a client side timer and show this to user like a kronometer. also i have something to do on button click event . if i use input(http) button could i use javascript code and click event together?
my english isnt ok so i cant explain what i mean clearly . i hope you can understand
openup your heart and let the sun shine in
|
|
|
|
|
Yes, you can call both Javascript function AND the ASP.Net click event postback using an input button.
If you are using an input button (not ASP.Net Button), then just add <input onclick="return functionName();>"
By returning the value of the function's result, you can choose to return true in your function if you want the input to do postback to the server or false if you don't.
"Democracy is two wolves and a sheep voting on what to have for dinner" - Ross
Edbert
Sydney, Australia
|
|
|
|
|
thanks edbert,
i will try it now
openup your heart and let the sun shine in
|
|
|
|
|
Hi all,
I am passing values from my datagrid to client side javascript function. In that some of the values contains apostrophes or quotes, which is creating error.I guess, this is because of values passed to browser are in ' ' quotes, and it encounter an apostrophes or quotes, that creates an error.
Anybody have some solution of this problem?
Please let me know.
Thank you very much,
NIKI
|
|
|
|
|
Try running the values through System.Web.HttpUtility.HtmlEncode()
|
|
|
|
|
That doesn't affect the apostrophes at all. Apostrophes has no special meaning in HTML, so they are not changed by the HtmlEncode method.
---
b { font-weight: normal; }
|
|
|
|
|
I have the same problem too.
I am a student at BBU in Cambodia.
In major: Information Technology.
This web is so interested.
|
|
|
|
|
Encode the string correctly to be a string value in Javascript:
theString = theString.Replace("\\", "\\\\").Replace("'", "\\'");
---
b { font-weight: normal; }
|
|
|
|
|
Hi Guffa,
I have a line in javascript function like this:
function myfunction(value1)
{
document.GetElementById('td').innertext=value1;
}
how can i parse the value1 field which contain apostrophes, such a way that it will not create problem while passing to the javascript function from server datagrid. and also, i dont want to eliminate apostrophes from the output on client side.
Thanks,
NIKI
|
|
|
|
|
You do as I showed when creating the code that calls that function.
---
b { font-weight: normal; }
|
|
|
|
|
Thank you very much Guffa,
The logic is perfectly working with my code.
Thank you very much.
I really appreciate your help.
NIKI
|
|
|
|
|
I have two web apps each using the asp.NET 2.0 Membership providers set with the same application name and the same database so when someone registers an account on one site it is available on the other as well. However, I would like to configure it so that when a user logs in on one site and follows a link to the second he is automatically authenticated on the second site. Is this possible?
|
|
|
|
|
I have a datagrid with a checkbox in it, when the checkbox is checked it writes its ID to a hidden control (via javascript). There is multiple pages in this datagrid, and when I go to page two, then back to page one, my checkbox's are not checked and the hidden control is not populated either.
Anyone know a trick to keep the checkbox's selected as well as the hidden textbox populated with each checkbox's id?
This is VS2003 and VB.Net
Steve Welborn
Software Engineer
BitWise Solutions
|
|
|
|
|
On the page change event store the values from the hidden control to a static hashtable where the Key is the unique id for the row and the value is a bool as to whether the checkbox is checked. Then in the DataBound event (or whatever the DataGrid equivilant is called) check each row id against the hashtable, if it finds an entry check/uncheck the checkbox accordingly.
|
|
|
|
|
Not a bad idea. I will try that tonight then and see if that solves it.
Thanks for the reply.
Steve Welborn
Software Engineer
BitWise Solutions
|
|
|
|
|
I currently have a datagrid (yes, the ongoing datagrid saga). I have one main datagrid and three nested datagrids.
(I took out the ASP code as it didn't copy right.)
This is how I bind the data to the main grid:
private void BindData()<br />
{<br />
strPartNumberInputReference = txtPartNumberInput.Text;<br />
<br />
<br />
<br />
string SQLString = "SELECT p.PartNumber, p.ID as ptID, pt.description, dd.DrawingNumber, dd.DrawingRevision, dd.DwgPath FROM parts p INNER JOIN PartTypes pt on pt.ID =p.PartTypeID LEFT JOIN DraftingData dd on dd.PartID = p.ID WHERE p.PartNumber = @PartID;SELECT w.weight, wt.Description AS wtDescription, p.PartNumber from weights w INNER JOIN weighttypes wt on wt.ID = w.weighttypeid INNER JOIN Parts p on w.PartID = p.ID WHERE p.PartNumber = @PartID;SELECT c.cost, p.PartNumber, ct.Description AS ctDescription from Costs c INNER JOIN Parts p ON c.PartID = p.Id INNER JOIN CostTypes ct on ct.Id = c.CostTypeID WHERE p.PartNumber = @PartID; SELECT s.SubPartID, s.Quantity, s.Sequence, p.PartNumber FROM SubParts s INNER JOIN Parts p ON s.PartID = p.Id "; <br />
SqlCommand cmd = new SqlCommand();<br />
cmd.Connection = new SqlConnection(strConnectSQL);<br />
cmd.CommandText = SQLString;<br />
cmd.Parameters.Add ("@PartID", strPartNumberInputReference);<br />
SqlDataAdapter adapter = new SqlDataAdapter(cmd);<br />
adapter.Fill(ds);<br />
<br />
ds.Tables[0].TableName = "Rest";<br />
ds.Tables[1].TableName = "Weights";<br />
ds.Tables[2].TableName = "Costs";<br />
ds.Tables[3].TableName = "Subparts";<br />
<br />
<br />
dgParts.DataSource = ds;<br />
dgParts.DataBind();<br />
Session["ptNum"] = strPartNumberInputReference;<br />
<br />
}
I played around and could not get the nested datagrids to populate. I got them to populate with variants of this:
protected DataView getWeightInfo (string _PartNumber)<br />
{<br />
DataView _weight = ds.Tables["Weights"].DefaultView;<br />
_weight.RowFilter = "PartNumber='" + _PartNumber + "'";<br />
return _weight;<br />
}
So to add a new line to the main datagrid I use this:
private void add_Click(object sender, System.EventArgs e)<br />
{<br />
DataTable dt = ds.Tables["Rest"];<br />
DataRow row;<br />
row = dt.NewRow();<br />
strPartNumberInputReference = txtPartNumberInput.Text;<br />
row["PartNumber"] = strPartNumberInputReference; <br />
row["DrawingNumber"]=DBNull.Value;<br />
row["DrawingRevision"]=DBNull.Value;<br />
row["DwgPath"]=DBNull.Value;<br />
dt.Rows.Add(row); <br />
dt.AcceptChanges(); <br />
dgParts.DataSource=dt; <br />
dgParts.DataBind();<br />
<br />
<br />
}
This works perfect. So I created a second button of "addWeight" and basically did the same thing:
private void addWeight_Click(object sender, System.EventArgs e)<br />
{<br />
DataTable dt = ds.Tables["Weight"];<br />
DataRow row;<br />
row = dt.NewRow();<br />
strPartNumberInputReference = txtPartNumberInput.Text;<br />
row["weight"] = DBNull.Value;<br />
row["wtdescription"] = DBNull.Value;<br />
dt.Rows.Add(row); <br />
dt.AcceptChanges(); <br />
dgWeights.DataSource=dt; <br />
dgWeights.DataBind();<br />
}
TWO problems:
1. It does not add a line to the weights nested datagrid. How to fix this?
2. If I add a line to the main datagrid first, then click the weights one, the first added line disappears. How to make the blank line static?
THANKS AGAIN ALL and sorry for the long post!
-- modified at 16:39 Tuesday 27th June, 2006
|
|
|
|
|
Maybe there is just something wrong on my end but the text in your post is all over the place, like css positioning gone wild. Like I said may just be me, Firefox 1.5
|
|
|
|
|
Oh, I forgot that when I cut and paste my ASP it never looks right.
|
|
|
|
|
hi
i want to know that how can i implement a menu bar in an webpage without using javascript is there any other way or software tool through which i can implement it as i am not in touch with javascript.
|
|
|
|
|
|
You could buy third party controls from a company like Telerik or upgrade to .NET 2.0
|
|
|
|
|
I've read some previous posts but am a bit confused. (Imagine that...) I have a webpage in an asp.net application in which the user enters a part number in a textbox.
strPartNumberInputReference = txtPartNumberInput.Text;
What I want to do is make this a session variable so that other pages can access this number. Basically the second web page will load data based on that part number entered.
Where within the code do I do this? Do I just put it in the first page? Within which function? Can I just do Session ["ptNum"] = strPartNumberInputReference and use it in the other pages. (I assume not as this doesn't seem to be working.) If I do the session in a function, does it have to be a public function?
As always, big thanks.
|
|
|
|
|
You may need to check your IIS settings to make sure session variables are enabled. Also check for session pooling for sessions to persist throughout the webspace. I have to believe that it must be a global setting in IIS.
|
|
|
|
|
leckey wrote: If I do the session in a function, does it have to be a public function?
No, you can do it in any function you want, in any page you want.
When you retrieve your object from session, be sure to cast it, as it is returned back as object
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
-- modified at 9:04 Wednesday 28th June, 2006
|
|
|
|
|
Elina Blank wrote: be sure to cast it, as it is returned back as string
Could you give me an example of what you mean?
Thanks!
|
|
|
|