|
Hi,
I have a following code
how to upload xml file to server.
// files upload function
function btn_send.onclick()
{
// create ADO-stream Object
var ado_stream = new ActiveXObject("ADODB.Stream");
// create XML document with default header and primary node
var xml_dom = new ActiveXObject("MSXML2.DOMDocument");
xml_dom.loadXML('<?xml version="1.0" ?> <root/>');
// specify namespaces datatypes
xml_dom.documentElement.setAttribute("xmlns:dt", "urn:schemas-microsoft-com:datatypes");
// create a new node and set binary content
var l_node1 = xml_dom.createElement("file1");
l_node1.dataType = "bin.base64";
// open stream object and read source file
ado_stream.Type = 1; // 1=adTypeBinary
ado_stream.Open();
ado_stream.LoadFromFile("c:\\tmp\\myfile.doc");
// store file content into XML node
l_node1.nodeTypedValue = ado_stream.Read(-1); // -1=adReadAll
ado_stream.Close();
xml_dom.documentElement.appendChild(l_node1);
// we can create more XML nodes for multiple file upload
// send XML documento to Web server
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("POST","./default.aspx",false);
xmlhttp.send(xml_dom);
// show server message in message-area
div_message.innerHTML = xmlhttp.ResponseText;
}
|
|
|
|
|
you can use file upload control that is already provided
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Hi,
I want to set the height and width of grid view control programmatically after databind is called. what ever may be the height's value, it is not getting applied to grid view.
can any body help me doing this.
VijayKrishna
|
|
|
|
|
try this
Gridview1.Width=Unit.persentage(100);
best regard
pathan
---------------------------------------------------
|
|
|
|
|
Hi again!
I want to move from SQL DB to MS Access but i have problem in converting SQL Data Types to Access Data Type while coding...
MS Access program Data Type are:
Text
Memo
Number
Date/Time
Currency
AutoNumber
Yes/No
OLE Object
Hyperlink
Attachment
What are the related data types From MS Access to OLEDB while coding?
.NET Framework Class Library MSDN!:
OleDbType Enumeration
Member name Description
BigInt A 64-bit signed integer (DBTYPE_I8). This maps to Int64.
Binary A stream of binary data (DBTYPE_BYTES). This maps to an Array of type Byte.
Boolean A Boolean value (DBTYPE_BOOL). This maps to Boolean.
BSTR A null-terminated character string of Unicode characters (DBTYPE_BSTR). This maps to String.
Char A character string (DBTYPE_STR). This maps to String.
Currency A currency value ranging from -2 63 (or -922,337,203,685,477.5808) to 2 63 -1 (or +922,337,203,685,477.5807) with an accuracy to a ten-thousandth of a currency unit (DBTYPE_CY). This maps to Decimal.
Date Date data, stored as a double (DBTYPE_DATE). The whole portion is the number of days since December 30, 1899, and the fractional portion is a fraction of a day. This maps to DateTime.
DBDate Date data in the format yyyymmdd (DBTYPE_DBDATE). This maps to DateTime.
DBTime Time data in the format hhmmss (DBTYPE_DBTIME). This maps to TimeSpan.
DBTimeStamp Data and time data in the format yyyymmddhhmmss (DBTYPE_DBTIMESTAMP). This maps to DateTime.
Decimal A fixed precision and scale numeric value between -10 38 -1 and 10 38 -1 (DBTYPE_DECIMAL). This maps to Decimal.
Double A floating-point number within the range of -1.79E +308 through 1.79E +308 (DBTYPE_R8). This maps to Double.
Empty No value (DBTYPE_EMPTY).
Error A 32-bit error code (DBTYPE_ERROR). This maps to Exception.
Filetime A 64-bit unsigned integer representing the number of 100-nanosecond intervals since January 1, 1601 (DBTYPE_FILETIME). This maps to DateTime.
Guid A globally unique identifier (or GUID) (DBTYPE_GUID). This maps to Guid.
IDispatch A pointer to an IDispatch interface (DBTYPE_IDISPATCH). This maps to Object.
This data type is not currently supported by ADO.NET. Usage may cause unpredictable results.
Integer A 32-bit signed integer (DBTYPE_I4). This maps to Int32.
IUnknown A pointer to an IUnknown interface (DBTYPE_UNKNOWN). This maps to Object.
This data type is not currently supported by ADO.NET. Usage may cause unpredictable results.
LongVarBinary A long binary value (OleDbParameter only). This maps to an Array of type Byte.
LongVarChar A long string value (OleDbParameter only). This maps to String.
LongVarWChar A long null-terminated Unicode string value (OleDbParameter only). This maps to String.
Numeric An exact numeric value with a fixed precision and scale (DBTYPE_NUMERIC). This maps to Decimal.
PropVariant An automation PROPVARIANT (DBTYPE_PROP_VARIANT). This maps to Object.
Single A floating-point number within the range of -3.40E +38 through 3.40E +38 (DBTYPE_R4). This maps to Single.
SmallInt A 16-bit signed integer (DBTYPE_I2). This maps to Int16.
TinyInt A 8-bit signed integer (DBTYPE_I1). This maps to SByte.
UnsignedBigInt A 64-bit unsigned integer (DBTYPE_UI8). This maps to UInt64.
UnsignedInt A 32-bit unsigned integer (DBTYPE_UI4). This maps to UInt32.
UnsignedSmallInt A 16-bit unsigned integer (DBTYPE_UI2). This maps to UInt16.
UnsignedTinyInt A 8-bit unsigned integer (DBTYPE_UI1). This maps to Byte.
VarBinary A variable-length stream of binary data (OleDbParameter only). This maps to an Array of type Byte.
VarChar A variable-length stream of non-Unicode characters (OleDbParameter only). This maps to String.
Variant A special data type that can contain numeric, string, binary, or date data, and also the special values Empty and Null (DBTYPE_VARIANT). This type is assumed if no other is specified. This maps to Object.
VarNumeric A variable-length numeric value (OleDbParameter only). This maps to Decimal.
VarWChar A variable-length, null-terminated stream of Unicode characters (OleDbParameter only). This maps to String.
WChar A null-terminated stream of Unicode characters (DBTYPE_WSTR). This maps to String.
__________
Sorry for this long post!
|
|
|
|
|
woff!!
is there any answer?!
|
|
|
|
|
Thanks&Regards,
Priya.
|
|
|
|
|
The only way is to use Javascript on the client side. You can add an attribute to do that to the ASP.NET control in Page_Load for example.
Assuming you have a button btnSubmit , you would do something like:
if (!IsPostBack)
{
btnSubmit.Attributes.Add("onclick","return confirm('Submit report?');");
}
The first parameter of the Attributes.Add method is the clientside event, the second parameter is any Javascript code you would like to execute.
Talal
-- If this is a post that has been helpful to you, please vote for it. Thank you!
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
Talal,
Talal Sultan wrote: btnSubmit.Attributes.Add("onclick","return confirm('Submit report?');");
Question was how to pop up a window. But this is different . Am I missing something ?
|
|
|
|
|
ooops, you're right. Popping up a message box is such a common question that I thought this is what the question was. Sorry my mistake
-- If this is a post that has been helpful to you, please vote for it. Thank you!
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
jus to make the record straight
btnSubmit.Attributes.Add("onclick","window.open('PagePath','WindowName','WindowAttributes');")
Regards
John
|
|
|
|
|
ASP.NET can't do anything on popping up a window. It can be done by client side scripting like Javascript. Try window.open("pagename") .
|
|
|
|
|
|
No,i didn't get it yet. actually i would like to open calendar control in a pop-up window when user clicks a button.
Thanks&Regards,
Priya.
|
|
|
|
|
Hi All...
i have one doubt that how can we control firing server side event based on returned value of client side function...
I am building one page which have one asp.net textbox, i have added one clientside event to it in pageload by:
TextBox1.Attributes.Add("onchange", "getClient();");
// i tried below one also, but no help
TextBox1.Attributes.Add("onchange", "return getClient();");
I am returning true or false based on some logic in client side function "getClient()". now my problem is that if getClient function is returning false, i want to stop server side TextChanged event from firing for the same textbox...
but in my case it's always firing server side textchnaged event...
how to achieve it? plz help me...
Akhilesh Singh
|
|
|
|
|
I'm no expert in this matter but I'm thinking if you check the source of the page and find out what is the event of the textbox that is causing the postback for the TextChanged server side event, maybe you can reassign this event to an empty string in Javascript. For example if you have a button, you would have something like that:
<input type="submit" name="ctl00$MainContent$btnLogin" value="Log In" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$MainContent$btnLogin", "", true, "", "", false, false))" id="ctl00_MainContent_btnLogin" .....
If you can find a way to reset the btnLogin call here: new WebForm_PostBackOptions("ctl00$MainContent$btnLogin", maybe you can prevent the server side event from calling the method assigned to it.
Sorry can't be of more help.
-- If this is a post that has been helpful to you, please vote for it. Thank you!
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
Thanks for reply sultan...
it was something new to me. but in my case if i will do it then server side will not be fired though my javascript function is returning true and my application is all set to the conditions when server side shpuld be fired. i think i am not wrong, but if i am wrong please let me know.
actually there is a way for this, if i use below for adding event to textbox:
<asp:textbox id="TextBox1" onchange="return getClient()" runat="server" autopostback="True" ontextchanged="TextBox1_TextChanged">
this works like if onchnage event bound jscript function (getClient in my case), is returning true then only server side textxhnaged will be fired. but for me it's not firing, i think because i am not following this approach nd adding event at page load (needed as asp.net textbox not having onchange)so this approach is not working.
Akhilesh Singh
|
|
|
|
|
akhilesh@slk wrote: TextBox1.Attributes.Add("onchange", "return getClient();");
Try this
TextBox1.Attributes.Add("OnKeyDown", "return getClient();");
|
|
|
|
|
Hi Navaneeth... that onchange event not making problem, as with that i am able to fire client side properly, also i am bound to use onchange in place of any other as if user use mouse to paste data in textbox directly without using keyboard then my event will not be fired.
what i think navaneeth anyhow what event i am using that is not reason of firing server side event, but the way i am relating my clientside change event to server side... some way is there to bound that returned value from clientside function to stop server side firing but i am not getting how?
please help me if you got how we can do that?
Akhilesh Singh
|
|
|
|
|
akhilesh@slk wrote: that onchange event not making problem
I still feel so.. Try the following
1- Add one textbox and set Autopostback=true
2- Page load add TextBox1.Attributes.Add("OnChange","MyFunction();");
3- Run the page and view source.
4- You will find textbox attribute like onchange="MyFunction();__doPostBack('TextBox1','')"
In this case MyFunction() will be called. But it won't stop if MyFunction() is returning false. So it will call __doPostBack() method which posts data.
akhilesh@slk wrote: bound to use onchange in place of any other as if user use mouse to paste data in textbox directly without using keyboard then my event will not be fired.
I feel it's better to go for KeyDown or KeyUp events. How about checking again on OnClick event ? This event will be fired when user pastes text.
|
|
|
|
|
Navaneeth first of all thanks for suggestion... it is really helpful but i think i am not lucky to use it in my problem. as if user just clicks on textbox without intention of pasting anything, then firing the onclick event is not good.
I think i need to give some more detail about what i am doing. here user will enter some text say "abc123", this is a search key based on this data i have to search mydatabase to get some details, i am using ajax for this. once user will fill textbox and focus goes out of textbox i will call my jscript function "getClient()", which will call a webmethod using ajax and will return a string. if string is not null, then i want to fire TextChanged event (server side), otherwise if string is null, this server event should not be fired. so this is all m trying to do. for this only my "getclient()" function is returning true if string is not null otherwise will return false...
also i am already following your point 1 and 2. i can't do anything which will permanently stop my server side, as i need it once returned string from database is not null.
if i am wrong anywhere please correct me
Akhilesh Singh
|
|
|
|
|
akhilesh@slk wrote: as if user just clicks on textbox without intention of pasting anything, then firing the onclick event is not good.
Yes I know it is not. But you can check textbox is null or not. If it is null then don't call AJAX method.
Sorry I am not getting any other method that could help you. Let me try once and let you know.
|
|
|
|
|
Sorry Navaneeth, i didn't tell you one condition as if already he has type something in textbox and after that he tries to click on textbox then as now textbox is not empty or null, we should not fire our any of onchange event as data is not changed, user just clicked on the textbox... and like this there are situation, we can put logic for this one but again some situation will come, so i am using onchange in place of any other event...
at last i am really thankful to you for replying as i am new to codeproject and didn't expect this much good response. thanks again...
Akhilesh Singh
|
|
|
|
|
when i am seeing source of my page, it is like this for textbox...
hope this can explain somewhat more about the problem.
Akhilesh Singh
|
|
|
|
|
fr33l0ad3r wrote: string classVal = "";
It looks like your variable is private. Declare it as public in the class.
|
|
|
|