|
I'm not an expert by any means on this, however I believe it might have to do with the point at the page event lifecycle when you create the controls. From what I understand any dynamic controls should be created very early in the page lifecycle and I use the Page_Init event always for dynamic controls and have had no problems with them. However I did have problems when trying to create them on page_load.
|
|
|
|
|
You shouldn't have any problem with adding controls in Page_Load. The Page_Init didn't event exist in framework 1.x.
---
b { font-weight: normal; }
|
|
|
|
|
Right, although they do recommend Page_Init and some 3rd party components I'm using require that as well because if you create them any later you don't get their values properly from viewstate.
http://support.microsoft.com/kb/317515
|
|
|
|
|
Yes, for some reason that is not revealed, it says that Page_Init is the best place for it, but it also says:
"When you create dynamic controls on a Web Form, you must create the controls and add them to the controls collection in either the Page_Init event handler or the Page_Load event handler."
So, either works for dynamic controls.
If some controls need to be created in Page_Init, it's because how they are built, not because you create them dynamically.
---
b { font-weight: normal; }
|
|
|
|
|
No, I looked a little deeper into it and you *must* create them in Page_Init if you want their viewstate to be restored properly because the event that loads viewstate into the controls occurs before Page_Load but after Page_Init.
|
|
|
|
|
Are you sure? Has this changed between framework 1.1 and framework 2.0? Otherwise it would be impossible to use dynamic controls in framework 1.1, as there is no Page_Init.
---
b { font-weight: normal; }
|
|
|
|
|
Maybe it's changed, not sure, I never used .net 1.x with asp.net, but that's been my experience with asp.net 2.0 and that's what Microsoft detailed on the page I found at the time when I looked it up on MSDN.
I use dynamic controls for a custom fields section on many of my forms and if I don't create them in page init then I can't retrieve their values later on in the page lifecycle.
|
|
|
|
|
Every postback produces a completely new Page object, so to make a dynamically created control stay on the page, you have to recreate it on every postback.
---
b { font-weight: normal; }
|
|
|
|
|
Hello,
When I create a web site I usually create an .aspx and an .aspx.vb file
for each page.
However, I create all my page code in my VB code at runtime.
What I would like to know is:
Is there a development model where the Aspx pages (.aspx files) are
also created at runtime.
If yes could you tell me if should I do it?
Can you give me any advice on creating everything at runtime in my VB
or C# code?
Thanks,
Miguel
|
|
|
|
|
hi!i have a problem for following code.
when i use this code in win-2000 server then there is no prblem
System.Windows.Forms.IDataObject clipboardData = System.Windows.Forms.Clipboard.GetDataObject();
but when try to execute this code in win-server 2003, then follwing exception is throwned
ex = {"Requested Clipboard operation did not succeed."}
please give me solution.
Amit Kuamr Pandey
|
|
|
|
|
I have an image inside a DIV tag.When i click the mouse in a IE browser,at the particular position of mouse click,i need to display the DIV tag's image.
I have captured the coordinates of the mouse click.
HOw to set the X,Y coordinates to the image i have taken inside the DIV tag using javascript.
|
|
|
|
|
You can declare your div for absolute positioning:
div {position: absolute; top: 100px; left: 100px;} and then change its position with something like this:
var e = document.getElementById("myDiv");
e.style.left = 110;
e.style.top = 110;
|
|
|
|
|
Here's a more fleshed-out example:
<html>
<head>
<style>
div.myDiv {font-size: 10pt; font-family: Tahoma;
border: 1px solid #999999;
background-color: yellow;
width: 18px; height: 18px;
position: absolute;
text-align: center;
vertical-align: center;
font-weight: bold;
color: darkBlue;
}
</style>
<script>
function findPos(obj) {
var curleft = curtop = 0;
if (obj.offsetParent) {
curleft = obj.offsetLeft
curtop = obj.offsetTop
while (obj = obj.offsetParent) {
curleft += obj.offsetLeft
curtop += obj.offsetTop
}
}
return [curleft,curtop];
}
function MoveDiv(x, y)
{
var div = document.getElementById("MyDiv");
div.style.left = x;
div.style.top = y;
}
function MoveToButton(btn)
{
var pos = findPos(btn);
var width = btn.offsetWidth;
var height = btn.offsetHeight;
var x = (width / 2) + pos[0];
var y = (height - 6) + pos[1];
MoveDiv(x,y);
}
</script>
</head>
<body>
<h3>Testing a client-side element move</h3>
<p>Div defined below:</p>
<div id="MyDiv" class="myDiv">
@
</div>
<br /><br />
<hr />
<input type="button" value="Click to move it here"
o n c l i c k = "MoveToButton(this);"
/>
<input type="button" value="Click to move it here"
o n c l i c k = "MoveToButton(this);"
/>
<input type="button" value="Click to move it here"
o n c l i c k = "MoveToButton(this);"
/>
<br /><br />
<input type="button" value="Click to move it here"
o n c l i c k = "MoveToButton(this);"
/>
<input type="button" value="Click to move it here"
o n c l i c k = "MoveToButton(this);"
/>
<input type="button" value="Click to move it here"
o n c l i c k = "MoveToButton(this);"
/>
<br /><br /><br /><br />
<a href="#";
o n m o u s e o v e r = "MoveToButton(this);"
>MouseOver move</a>
<a href="#";
o n m o u s e o v e r = "MoveToButton(this);"
>MouseOver move</a>
</body>
</html>
|
|
|
|
|
hello
like i have one aspx/asp page which iam using in my many anither pages so i don't want to write all the stuff every time how can i do this?
i tried with
its not working
and i also tried with
response.writefile("file.aspx")
its working but i want to use some functions of file.aspx page in my present page -----------its throwing an error there because it adds the file at run time and the function in it has not declared before
so how can i do this
can any one suggest me ------------
|
|
|
|
|
Hi,
I think you must use ASP.NET User Controls (*.ascx)
|
|
|
|
|
hello
like i have one aspx/asp page which iam using in my many anither pages so i don't want to write all the stuff every time how can i do this?
i tried with
its not working
and i also tried with
response.writefile("file.aspx")
its working but i want to use some functions of file.aspx page in my present page
|
|
|
|
|
You have to create user controls for that purpose. They are just like your aspx pages and you can drag and drop to any page you want. The extension for that is ascx.
Best Regards,
Apurva Kaushal
|
|
|
|
|
but i have "response.write" stmts in my page how can it work
any other way?
can any one send me one example?
|
|
|
|
|
It does not matter. What you need to do is first create a ascx page(User control). Same as you create a aspx page and then drag it from solution explorer to you web page(aspx page) and that over. You can get the contents of the control to the page.
Best Regards,
Apurva Kaushal
|
|
|
|
|
thanks alot for a very fsater reply
but still iam getting prob because i have some functions in my first page which are having response.write stmts ok and i want to use these functions in my second page.........iam getting reference error
thanks in advance
|
|
|
|
|
I am not been able to understand your because i dont think there is any relation between your user control and response.write statements. What is the exact error message and you debug the code and see where which part is diaplaying the error.
Best Regards,
Apurva Kaushal
|
|
|
|
|
hai apurva
let me explain what i need exactly
ihave one.aspx page ok in that i have written some functions to display some table of content ok
for example...
in my one.aspx ihave a function like...
function disp(pagesize,query...etc)
(iused record set of adodb here to fech the table from param query passed ok)
response.write("")
(taken loop to display)
response.write(")
and so on.
now i want to use this function in my second.aspx
i think now it is clear
thanksrecods that feched from table |
|
|
|
|
|
If you just want to use that function in multiple pages then what you can so is place that function in a class file and then call it from the pages where ever you want.
Best Regards,
Apurva Kaushal
|
|
|
|
|
Can I implement lostfocus, gotfocus and keypress events in ASP.Net as in VB6.0
Nandini Sharma
|
|
|
|
|
Those events occur in the browser, so you use client script, i.e. Javascript, to handle them. They are named onfocus, onblur and onkeypress.
---
b { font-weight: normal; }
|
|
|
|