|
Hello,
I did some testing and realized that for some reason I still haven't figured out when the code is run from a Web Service the password is not even set. It is as if these lines did not execute:
newUser.Invoke("setpassword", password);<br />
newUser.CommitChanges();<br />
newUser.Properties["userAccountControl"].Value = 0x200;<br />
newUser.CommitChanges();
Like I said, this exact same code runs a-Ok from a Windows App, but not from a Web Service.
|
|
|
|
|
Okay, figured out my error. I was missing some impersonate settings on the Web App. Solved now
|
|
|
|
|
Hi guys,
I have used following code
Response.AppendHeader( "content-disposition", "attachment;filename=" + FilePath );
Response.WriteFile(FilePath);
Response.End();
to get the download dialog box for one file on my server. Can any body tell me how can i get the response (Whether user has clicked Open, Save or Cancel button)???
Thanks in Advance
|
|
|
|
|
I don't believe that you can. Thie "open/save/cancel" options are handled entirely within the browser and do not send any data to the browser. The job of the server is simly to send the stream to the client and be done with it. The browser is responsible for receiving the stream and then asking the user what to do with it, which requires no server interaction.
|
|
|
|
|
Thanks Jim,
Is there any way to do same functionality?
|
|
|
|
|
I am using an ASP.NET 2.0 TreeView and was wanting to create different child TreeNode types for the different items that I am loading into the treeview. The idea behind this is that all I should have to do is check the node type when a node gets clicked and I can then respond accordingly. The problem, however, is that the child treenode I created that inherits from TreeNode gets reported to be a normal TreeNode type rather than the inherited treenode type when I use the typeof operator even though I instantiate it as the child TreeNode type. Am I missing something?
class Child1TreeNode : TreeNode
{
}
class Child2TreeNode : TreeNode
{
}
And then in the Page Load:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Child1TreeNode node = new Child1TreeNode();
node.Text = "Hello World";
node.Value = "1";
Child2TreeNode node2 = new Child2TreeNode();
node2.Text = "Goodbye World";
node2.Value = "2";
TreeNode topNode = TreeView.FindNode("Top");
topNode.ChildNodes.Add( node );
}
}
And then in the event handler for node changed:
protected void TreeView_SelectedNodeChanged(object sender, EventArgs e)
{
TreeNode node = ((TreeView)sender).SelectedNode;
if (node.GetType() == typeof(Child1TreeNode) )
{
}
else if (node.GetType() == typeof(Child2TreeNode) )
{
}
}
Thanks.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Hi there,
What you are missing is that you also need to extend the TreeView control and override the CreateNode method. This method is basically used on postback to recreate the nodes tree, and by default it returns the TreeNode type and has no idea about your custom Child2TreeNode .
|
|
|
|
|
Web programming has all those little gotchas. I never seem to get over that.
Anyhow, thanks for your help. Here's another question for you, though. How can I override the CreateNode method so that I can pass it an assortment of different objects that inherit from TreeNode and have them all retain their identity?
Thanks again,
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Here you want to use multi different types of the tree node such as Child1TreeNode , Child2TreeNode , so you need a way to determine which object should be created when the treenode is rebuilt on postback. And the ViewState comes to mind as an option when you can use it to persist the node type in order to recreate the tree node. However, when you create a tree node in the overriden CreateNode method in the custom treeview, the ViewState of the tree node has not been loaded yet, so you will do that as soon as the ViewState is loaded. In the CreateNode, you simply return the base class of your two node types, say ChildTreeNode , and you will replace this base node with the exact type after the node type is determined. Below is the sample code to demonstrate this thing:
public class ExTreeView : TreeView
{
protected override TreeNode CreateNode()
{
return new ChildTreeNode(this);
}
}
public class ChildTreeNode : TreeNode
{
public ChildTreeNode() { }
public ChildTreeNode(string nodeType) { m_NodeType = nodeType; }
public ChildTreeNode(ExTreeView owner) { this.m_Owner = owner; }
private ExTreeView m_Owner;
internal ExTreeView Owner { get { return m_Owner; } }
private string m_NodeType;
internal string NodeType
{
get { return m_NodeType; }
set { m_NodeType = value; }
}
protected override object SaveViewState()
{
object baseState = base.SaveViewState();
return new Pair(baseState, NodeType);
}
protected override void LoadViewState(object savedState)
{
Pair p = savedState as Pair;
base.LoadViewState(p.First);
NodeType = p.Second as string;
TreeNode newNode;
if (NodeType == "Child1TreeNode") { newNode = new Child1TreeNode(); }
else if (NodeType == "Child2TreeNode") { newNode = new Child2TreeNode(); }
else { newNode = new TreeNode(); }
newNode.Text = this.Text;
newNode.Value = this.Value;
ReplaceCurrentNode(this, newNode);
}
private void ReplaceCurrentNode(ChildTreeNode currentNode, TreeNode newNode)
{
TreeNodeCollection nodes;
if (currentNode.Parent == null)
nodes = currentNode.Owner.Nodes;
else
nodes = currentNode.ChildNodes;
int index = nodes.IndexOf(currentNode);
nodes.Remove(currentNode);
nodes.AddAt(index, newNode);
}
}
public class Child1TreeNode : ChildTreeNode
{
public Child1TreeNode() : base("Child1TreeNode") { }
}
public class Child2TreeNode : ChildTreeNode
{
public Child2TreeNode() : base("Child2TreeNode") { }
}
To make the sample code simpler, you may think of only using a single custom type instead of multi types to represent the tree nodes, and you can have an additional property to represent the node type. Doing so, you only need to recreate this node type in the overriden CreateNode method of the custom treeview.
Another option is that you don't need to create a custom treeview control and override the CreateNode method, what you need to do is to disable the ViewState by setting EnableViewState to false , and in the Page_Load you don't check the IsPostBack and leave the code to create the tree nodes outside the if statement.
|
|
|
|
|
Hello everyone:
I need to get some information about TableAdapters programatically. When I create a new instance of my DataSet like this:
<br />
DataSet ds = new DataSet();<br />
ds.ReadXmlSchema(MyDataSetFile);<br />
I can retrieve the information about DataTables but I dont see a way to retrieve information about TableAdapter. Any Ideas how to do it?
In an MSDN[^] article, it says to get to TableAdapter we will need a new instance of the TableAdapter and then it gives this example:
<br />
NorthwindDataSet northwindDataSet = new NorthwindDataSet();<br />
<br />
NorthwindDataSetTableAdapters.CustomersTableAdapter customersTableAdapter = <br />
new NorthwindDataSetTableAdapters.CustomersTableAdapter();<br />
<br />
customersTableAdapter.Fill(northwindDataSet.Customers);<br />
In my case I dont know which DataSet I will be working with untill runtime. Please help.
Thanks.
Regards,
Robert
|
|
|
|
|
TableAdapters are designer-generated components.
only two letters away from being an asset
|
|
|
|
|
I think, you need to creat typed DataSet to work with Table Adpater programmtically ........which will be generated code...
Sonny...
Sanjeev
|
|
|
|
|
Is php a server side script language?
|
|
|
|
|
That's true when using in Web Programming
|
|
|
|
|
Sir,
I am beginner in php.Not made a single project or a program.May I get some links to enrich my knowledge.
Thanks
|
|
|
|
|
You might want to post to the Web Development forum since this question has nothing to do with ASP.NET. You may also want to find out what the language is before asking questions.
only two letters away from being an asset
|
|
|
|
|
I had write a WebControl and its designer.The following is som of my code
<br />
[Designer("SM.WebControls.PagingControlDesigner"),<br />
ParseChildren(false)]<br />
public class PagingControl : System.Web.UI.WebControls.WebControl,INamingContainer<br />
{<br />
[Bindable(true),<br />
EditorAttribute(typeof(UrlEditor), typeof(UITypeEditor))] <br />
public string FirstButtonImg<br />
{<br />
get{return Convert.ToString(ViewState["FirstButtonImg"]);}<br />
set{ViewState["FirstButtonImg"] = value;}<br />
}<br />
<br />
protected PlaceHolder ParsedSubObjectContainer = new PlaceHolder();<br />
protected override void CreateChildControls()<br />
{<br />
Panel Panel1 = new Panel();<br />
Create some Controls and add to Panel1<br />
Controls.Add(Panel1);<br />
Controls.Add(ParsedSubObjectContainer);<br />
}<br />
protected override void AddParsedSubObject(Object obj)<br />
{<br />
ParsedSubObjectContainer.Controls.Add((Control)obj);<br />
}<br />
<br />
internal string GetDesignTimeHtml()<br />
{<br />
EnsureChildControls();<br />
StringWriter sw = new StringWriter();<br />
HtmlTextWriter writer = new HtmlTextWriter(sw);<br />
this.RenderControl(writer);<br />
return sw.ToString();<br />
}<br />
...<br />
}<br />
public class PagingControlDesigner : ControlDesigner<br />
{<br />
public override bool DesignTimeHtmlRequiresLoadComplete<br />
{<br />
get{ return true;}<br />
}<br />
<br />
private PagingControl PagingControlInstance;<br />
<br />
public override void Initialize(System.ComponentModel.IComponent component)<br />
{<br />
this.PagingControlInstance = (PagingControl) component;<br />
base.Initialize (component);<br />
}<br />
<br />
public override string GetDesignTimeHtml() <br />
{<br />
return PagingControlInstance.GetDesignTimeHtml();<br />
}<br />
...<br />
}<br />
I faced two problems when I writing this WebControl.
The First is when I try to bind the FirstButtonImg property in a web form, the expression is not evaluated.It simple pass the '<%= Expression %>' string to the property
<br />
<SM:PagingControl id="PagingControl1" runat="server" <br />
FirstButtonImg='<%= Expression %>'<br />
><br />
I do call PagingControl1.DataBind() in my WebForm's code.
The second, when I am designing a WebFrom:
<br />
<SM:PagingControl id="PagingControl1" runat="server"><br />
<asp:DataGrid id="DataGrid1" runat="server"><br />
</asp:DataGrid><br />
</SM:PagingControl><br />
Only the Panel(Panel1) is displayed in the designer.But the ParsedSubObjects(here is DataGrid1) is not displayed.How can I get the ParsedSubObjects'(here is DataGrid's) DesignTimeHTML to display it in the designer.
Can any one help me? Any idea will be appropriate.
|
|
|
|
|
How can I keep the page focused on a specific control after I've performed a postback?
I have a datagrid located on the bottom of my page. Each row contains a ButtonColumn, which when clicked, changes an image located alongside the grid.
My problem however is every time the user clicks a button in the grid, a Postback is performed and after the page refreshes, it returns the user back up to the top of the page (which can be quite annoying when you're performing clicks on 30-40 different rows).
So how can I prevent the page from returning back to the top every time?
Thanks.
-Goalie35
|
|
|
|
|
Add this function into your global module:
Public Function SetFocus(ByVal FocusControl As Control) As String<br />
'Setting focus to supplied control<br />
Dim Script As New System.Text.StringBuilder<br />
Dim ClientID As String = FocusControl.ClientID<br />
<br />
'Building java script<br />
With Script<br />
.Append("<script language='javascript'>")<br />
.Append("document.getElementById('")<br />
.Append(ClientID)<br />
.Append("').focus();")<br />
.Append("</script>")<br />
End With<br />
<br />
Return Script.ToString()<br />
End Function
Call the function above from your from passing control to be focused:
RegisterStartupScript("setFocus", Utilities.SetFocus(TextBox1))
==postmaster
www.programmingknowledge.com
|
|
|
|
|
use the MaintainScrollPositionOnPostback page directive
only two letters away from being an asset
|
|
|
|
|
Try this
Add this function into your global module:
Public Function SetFocus(ByVal FocusControl As Control) As String
'Setting focus to supplied control
Dim Script As New System.Text.StringBuilder
Dim ClientID As String = FocusControl.ClientID
'Building java script
With Script
.Append("")
.Append("document.getElementById('")
.Append(ClientID)
.Append("').Select();")
.Append("")
End With
Return Script.ToString()
End Function
Call the function above from your from passing control to be focused:
RegisterStartupScript("setFocus", Utilities.SetFocus(TextBox1))
|
|
|
|
|
This appears to be exactly, verbatim what postmaster@programmingknowledge.com posted about 2 hours before you.
Now the question is did you both copy it from the same source, did you copy from his post, or possibly is it from The Osmosian Order Handbook?
only two letters away from being an asset
|
|
|
|
|
The RowCommand is raised when a user presses a button on a GridView. Could someone please tell me how I can programmatically raise the RowCommand of within the event handler of another instance of an object? Paste some simple code if you can.
|
|
|
|
|
|
You can call any event just like you would any other method...you just need the right parms. The RowCommand event handler looks like this:
Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
End Sub
So you have to send it an Object and a System.Web.UI.WebControls.GridViewCommandEventArgs
I don't know what all of the event arguments are, but you can use intellisense to help you figure out what you need...maybe this will help you get started:
Dim myOrginalArgs As New System.Web.UI.WebControls.CommandEventArgs(myCommandName, myArgument)
Dim myGridViewCommandEventArgs As New System.Web.UI.WebControls.GridViewCommandEventArgs(myGridViewRow, myOrginalArgs)
GridView1_RowCommand(myObject, myGridViewCommandEventArgs)
|
|
|
|