|
Viewstate only seems to remember specific changes. Look at the following code, for example.
if (!Page.IsPostBack)<br />
{<br />
string str = "<script type='text/javascript'>";<br />
str += "document.getElementById('CheckBox3').style.visibility='hidden';";<br />
str += "document.getElementById('CheckBox2').checked=true;"; <br />
str += "</script>"; <br />
Response.Write(str);<br />
}
It will add javascript to check checkbox2, and hide checkbox3 on the clicent side if it's not a postback. Now do a postback. Checkbox2 will stay checked, but checkbox3 will turn visible after a postback. Viewstate is enabled for both checkboxes.
|
|
|
|
|
Well, I am surprised it remembers the check, and you're lucky it works at all. This is silly code. Set the Visible and Checked properties on the .NET class instances, and both will be remembered.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
It remembers the check, because that's how any html form remembers the check or textfield data during postback.
Of course this can be done on the server side and be remembered, and probably most examples are silly. This was not the question
Then think of this, as it's more like a real life example: The user can show or hide a div with a button (client side code). This div should not magically appear after a postback if it's hidden or vice versa.
Postback is slow. You don't want to postback and wait just to hide something, to change the backcolor or to sort a table when it can be done instantly on the client side.
|
|
|
|
|
derm2 wrote: Postback is slow. You don't want to postback and wait just to hide something, to change the backcolor or to sort a table when it can be done instantly on the client side.
I agree. But, when I do client side stuff, I don't expect viewstate to find it all, I would tend to use a server hidden control to store values telling me what I had done on the client side in script.
I get what you're saying, viewstate would be cooler if it worked better. I guess I'm just saying I'm glad when stuff works at all :P
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks for the input, the hidden field should do the job.
And we shall see what they make for us in the next version of ASP.net
|
|
|
|
|
Hey
Well i have like 300 computers on my network and most of them are running on windows 98 .
my friend build a web application that asks the user for a catalog
number and in javasciprt it display the "catalognum.jpg"
the problem is that after the user load something like 20 pictures
the page is not showing more pictures,it's look like that there is no memory ....
here is most of the code
function myfunction(filpath)
{
if (filpath !== "")
{
imgtasrit.src = "DocLib/"+filpath+".jpg";
}
else
{
imgtasrit.src = "image003.gif";
}
}
/script>
.....
input type = button value="??? ?????" onclick="myfunction(form1.tb1dk.value)" align="right" id="Button1" >
i just wondering if there is way to clean the memory on client side ?
|
|
|
|
|
This is using ASP.NET ? I'd still ask in the web dev forum, as it's a generic client side question.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi.
I am creating a website that will have timed exams, I want to setup the timer in my asp.net application and I want the timer to be updated (using javascript) in th UI. when the time ends I want an automatic submission of the page.. any idea how to do this using asp.net + javascript? I also need to know the value of the timer each time the page is submitted..
Many Thanks
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
AJAX.............Will be helpful...
Dont Get Paid for the Hours you worked, Get Paid for the Work You Have Done in an Hour.
|
|
|
|
|
Any details, plz?
I need the simplest way for implementing this thing . Thanks
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
You don't need AJAX at all, although you could use it. Just set a timer using one of the many javascript timer code examples that exist on the web. Set the users starting time on the server, and always use that to reset the timer on postback ( it's so easy to change client side script, you should never rely on it being correct ).
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I am writing a WebPart for SharePoint and am having trouble re-painting a control (not ASP control) when I want to reflect some scripting action.
My class inherits from "Microsoft.SharePoint.WebPartPages.WebPart".
I found the ASP listbox control lacking because I wanted to include a checkbox, graphics as well as text for each item.
An array of checkboxes contained within a div (for scrolling) contained in a feldset (for a border to contain the entire set) made for a good display of the data with the ability to access each item individuality.
The array is rendering the way I want it with a checkbox, icon and text for each item and the scrolling is working properly.
I am able to check and un-check each individual item in the array of checkboxes but the CheckAll() and ClearAll() functions are not checking or clearing all the items in the array.
Can anyone tell me what I need to do to make the CheckAll() and ClearAll() functions work?
In "protected override void RenderContents(HtmlTextWriter writer)"
<br />
writer.Write("<fieldset style='width: 760px;'>");<br />
writer.Write("<legend><strong>" + lblDocInfo.Text + "</strong></legend>");<br />
<br />
writer.Write("<div style='overflow: auto; height: 145px;'>");<br />
<br />
foreach (string folder_key in current_folders)<br />
{<br />
writer.Write("<input type=checkbox name='" + folder_key + "' id='" + folder_key + "'><img src='http://sharepointservername/projectname/websitename/icons/folder.ico' align='middle'> " + folder_key.Substring(folder_key.LastIndexOf("/") + 1) + "</input><br />");<br />
}
<br />
foreach (string doc_key in current_docs)<br />
{<br />
writer.Write("<input type=checkbox name='" + doc_key + "' id='" + doc_key + "'><img src='http://sharepointservername/projectname/websitename/icons/doc.ico' align='middle'> " + doc_key.Substring(doc_key.LastIndexOf("/") + 1) + "</input><br />");<br />
}
<br />
writer.Write("</div>");
<br />
writer.Write("</fieldset>");<br />
<br />
writer.Write("<br /><br />");<br />
writer.Write("<input id='btnCheckAll' type='button' value='Check All Documents' onclick='CheckAll();' style='width: 380px;' />");<br />
writer.Write("<input id='btnClearAll'type='button' value='Clear All Checked Documents' onclick='ClearAll();' style='width: 380px;' />");<br />
writer.Write("<br />");<br />
btnProcess.RenderControl(writer);<br />
writer.Write("<br /><br />");<br />
and further down in the code
<br />
writer.Write("<script type='text/javascript'>");<br />
<br />
writer.Write("function CheckAll(){");<br />
foreach (string doc_key in current_docs)<br />
{<br />
writer.Write("document.getElementById(doc_key).checked = true;");<br />
}
writer.Write("document.getElementById('btnClearAll').disabled = false;");<br />
writer.Write("}");
<br />
writer.Write("function ClearAll(){");<br />
foreach (string doc_key in current_docs)<br />
{<br />
writer.Write("document.getElementById(doc_key).checked = false;");<br />
}
writer.Write("document.getElementById('btnClearAll').disabled = true;");<br />
writer.Write("}");
<br />
writer.Write("</script>");<br />
|
|
|
|
|
What does it mean ?
How does it occur ?
and what should I do ?
It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
Tnx
|
|
|
|
|
razi_Seyyedi wrote: This error can be caused by a virtual directory not being configured as an application in IIS.
There you go. I suggest you read the article I link to in my sig, especially the bit on researching error messages.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
It means that you have an application level section in a web.config file that is not in the root folder of your web.
Either you have put an illegal section in a web.config file in a folder in your application, or what you think is the root folder of your application is just a folder in another application.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
... instead of creating Resource files for each language.
Is it possible?
---
Harsh Gupta
|
|
|
|
|
Are you Sonia's brother ?
What do you mean by 'dynamic' ? Creating resources for each language is the best way I can think of to create resources so you can change the language of your site, if you wanted it to happen via some translation algorithm or something, that could only end in tears.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hi,,
on my project asp.net with c#
I added a javascript item for eg,, name : JS.js
and made the next function :
function PopUpQtyWindow(id)<br />
{<br />
window.open("productqty.aspx?id=" + id, "Cart", "status = 1, height = 150, width = 200, resizable = 0"); <br />
}
then on any page i tried to call this function as next :
<br />
int prodID = 1 ;<br />
HyperTest.NavigateUrl = "javascript:PopUpQtyWindow(" + prodID + ");";
when running project and press the hyperTest .. status message " Error on page " .
thanks for all .
jooooo
|
|
|
|
|
1. What error message you get?
2. Do you have configuration like down below?
<br />
.<br />
.<br />
.<br />
<script type="text/javascript" src="JS.js"><br />
</script><br />
.<br />
.<br />
.<br />
I Love T-SQL
|
|
|
|
|
thanks for your reply my friend
the error message is appear on the status bar of the internet explorer :
Error on page,
that is the error message ,, no debug
jooooo
|
|
|
|
|
You can click on that error message to show you details, so you can see what the error is. Either the function is not present, or it's got an error in it.
I would recommend installing firefox and the firebug add on, then you can debug your javascript inside the browser.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I will install it and try ,,
thanks my friend
jooooo
|
|
|
|
|
Hi,
Test this way:
<br />
protected void HyperTest_OnClick(object sender, EventArgs e)<br />
{<br />
try<br />
{<br />
int prodID = 1 ;<br />
Page.ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "PopUpQtyWindow(" + prodID + ");", true);<br />
}<br />
catch (Exception ex)<br />
{ <br />
throw;<br />
}<br />
}<br />
|
|
|
|
|
Really thanks for your reply ..
on my example the code as next :
HyperTest.NavigateUrl= ....
when i use the code :
HyperTest.NavigateUrl= Page.ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "PopUpQtyWindow(" + prodID + ");", true);
then error message:
Cannot implicitly convert type 'void' to 'string'
thanks for aiding me
jooooo
|
|
|
|
|
No no, HyperTest.NavigateUrl is wrong.
Say, I test your code in this way:
<br />
<script type="text/javascript" language="javascript"><br />
function PopUpQtyWindow(prodID)<br />
{<br />
alert(prodID);<br />
}<br />
</script><br />
<asp:linkbutton id="HyperTest" runat="server" onclick="testClick" text="Test"></asp:linkbutton><br />
And in behind:
<br />
protected void testClick(object sender, EventArgs e)<br />
{<br />
int prodID = 1;<br />
Page.ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "PopUpQtyWindow(" + prodID + ");", true);<br />
}<br />
This code is working on both IE and firefox browsers.
|
|
|
|