|
The <%=...%> tag is a server tag to output a value. It's almost equivalent to <script runat="server">Response.Write(...)</script> .
The ClientID property of a server control contains the id that the control uses for the html element that it renders. When server controls are inside a container (like a user control) the id is prepended with the id of the container to keep it unique in the form. You use the ClientID property to get this generated id.
---
single minded; short sighted; long gone;
|
|
|
|
|
|
that means you are trying to access the server variable on client side.. hope so it will clear the problem
Sarfaraz Nazir
Solution Developer
Accentys Inc
|
|
|
|
|
|
Hi,
I have a web part page with a toolbar webpart and a grid webpart. In the toolbar, I have menu-items to update a field.
For selecting the value of the field I have another asp.net webform which shows the various options in a dropdownlist.
This form has to be a modal form and has to be shown on click the Toolbar menu items. When the user selects an option from the drop-down list and click OK then the option selected has to be
returned to the web-part page from where the webform was shown.
I'm able to do this when I have a Webform and not a sharepoint webpart page as the parent page. When I use a sharepoint web-part page, this doesn't work.
Code Snippet:
grid webpart(in a webpart page):
• Code-behind
void webpart_SetToolbarMenuItemProperties(object sender, SetMenuItemPropertiesEventArgs e)
{
switch (e.MenuItem.MenuItemAOTName.ToLower())
{
case "smmmileadchangestatuspostpone":
e.MenuItem.ClientOnClickScript = "UpdateStatusWindow()" ;
break;
}
}
• Html source
function UpdateStatusWindow()
{
var returnVal = window.showModalDialog('http://localhost/_layouts/ep/smmLeadReasonId.aspx','','dialogWidth:200px;dialogHeight:120px;status:no');
alert (returnVal);
Aasp.net form shown as modal form
• Html source
function Close()
{
window.returnValue = getSelectedReason();
window.close();
}
function getSelectedReason()
{
return form1.ddlUpdateStatus.value;
}
If anyone has some idea why this is not working, please provide your inputs.
Thanks,
Manpreet
|
|
|
|
|
Hello,
I have a 'select' element in the footer of my masterpage. I'm trying to write javascript to assign a handler to the 'onchange' event of the 'select' control. The javascript is as follows:
var selectDisplay = document.getElementById('selectDisplay');<br />
selectDisplay.onchange = function()<br />
{<br />
alert("You did it!");<br />
}
The id of the 'select' element is 'selectDisplay'.
I have found references to issues regarding using getElementById when the element you want is in the masterpage, but have been unable to find a solution.
Any ideas?
Thanks!
Ian
|
|
|
|
|
Mundo Cani wrote: selectDisplay.onchange
Try setting it up something like this:
<title>Untitled
function OptionSelect(){
var sel = document.getElementById("selectDisplay");
for(i = 0; i < sel.length; i++){
if(sel[i].selected){
i ? alert('Option ' + sel.value + ' selected') : alert('Select an Option');
break;
} // if(sel[i].selected)
} // for(i = 0; i < sel.length; i++)
} // OptionSelect()
onchange="OptionSelect();">
Select an Option
Option 1
Option 2
Option 3
Option 4
|
|
|
|
|
JimmyRopes wrote: var sel = document.getElementById("selectDisplay");
Thanks for your reply. Unfortunately, the problem is getElementById does not return an element. I pass it the id of the element I'm looking for (there is no mispelling... I copy/pasted the id) but it is not returned.
Ian
|
|
|
|
|
Mundo Cani wrote: Unfortunately, the problem is getElementById does not return an element.
That is very strange.
As an exercise I just swiped the code in my rely from the <html> to the </html> and put it into a new document in notepad.
I saved the document as test.htm and then clicked on the saved document. A browser window came up and the control worked as intended. I didn't add or take anything away but just used the code posted.
Try it and see if you get the same results.
There is no problem with getElementById. I use it all the time on my web pages.
|
|
|
|
|
I got it working. I was confused with the difference between client-side and server-side controls. Thanks!
Ian
|
|
|
|
|
Mundo Cani wrote: there is no mispelling... I copy/pasted the id
That doesn't help, as you are copying the id that is used for the server control. The getElementById method is using the id of the html element that the control renders, and if you examine the rendered html code (view source in the browser) you will see that they are not the same.
---
single minded; short sighted; long gone;
|
|
|
|
|
|
When a control is in a container (like a content control of a master page), the id is prepended with the id of the container.
Use the ClientID property of the control to get the id that you can use in client script, or view the source of the generated page to find out the generated id.
---
single minded; short sighted; long gone;
|
|
|
|
|
Ian
When control is in master page then the client side rendering of the webpage automatically genrate Id's for the server side control you need to traverse all the elements in the content regardless of using "document.getElementById('selectDisplay');" coz it will definetly not work
Thanks
Sarfaraz Nazir
Solution Developer
Accentys Inc
|
|
|
|
|
Thanks for your help!
Ian
|
|
|
|
|
Hi Guys,
Is there a way wherein I can place the "text" of Linkbutton in center position?
Because what happened was, when I removed the underline the text is automatically adjusted to top position.
What I want is a LinkButton with transaparent background color, no borders and the text should be in center position (valign = center).
Could this be possible?
Thanks in advance Guys.
hifiger2004
|
|
|
|
|
if you put any tags in your server control that are not recognised by the framework, they get passed through to the client. so, you can add a style tag, or any other tag you like that pertains to the control that gets rendered.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi Christ,
I wanted to follow your advice, but with regards to style tag I can't picture out if how am i going to do it. I hope you will send me a sample of Linkbutton that has a style tag.
What I need is a simple asp.net LinkButton control with text "Search" and will displayed with valign = "center" or "middle"
Please see this link - http://cvd.harnesstheweb.com
If your browser is IE6 or IE7, you will noticed here that the menus on the header are not in center position. This is because the LinkButton control has no valign property.
Do you have another idea on how to move the text vertically to the center of the Linkbutton?
hifiger2004
|
|
|
|
|
Hi
I am working with AJAX Panel Collapsable panel extender. The Panel which is to be collapsed/Expanded using AJAX panel Extender contains one custom control, containing 3 Radio buttons one of them is set checked through a javascript function when page loads.
I have kept the default property of AJAX collapsable panel as Collapsable.
But problem is that when page loads, collapsible panel gets collapsed but it resets the radio buttons in custom control. i.e. First radio button does not get checked.
Script for Collpsable panel is as follow.
<ajax:collapsiblepanelextender id="cpeSOP" runat="Server" collapsecontrolid="pnlCollapsable"
="" collapsedsize="0" collapsed="True" collapsedimage="~/public/img/arrowRightWhite.gif" expandcontrolid="pnlCollapsable" expanddirection="Vertical" expandedimage="~/public/img/arrowDownWhite.gif" imagecontrolid="Image1" suppresspostback="true" targetcontrolid="pnlSearchCriteria">
I want to call some javascript code when the panel is Collapsed or Expanded.
Is there any way to track Collapse / Expand event (client side / server side) of AJAX Collapsable Panel Extender ?
If so it will be my pleaseure to know this as early as possible, as i am fighting on this problem since long time.
Thank you.
Sarang Deshpande
|
|
|
|
|
in my app, i want to retrieve images from database for different users currently i m doing this with filestream but it not working properly so if there any other idea plz help me.[i m using c#]
|
|
|
|
|
If you're using C#, you are probably using ASP.NET, although it sounds like a general C# question to me.
What do you mean by 'not working properly' ? Obviously, there's no reason for it not to work if it's done right. If you explain your approach, and show some code, perhaps we can help.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi
thanx for response
here my code:
string strconapprove = ConfigurationSettings.AppSettings["connection"].ToString();
string strcmdapprove = "select * from coc_prayer_request_pending where ID='" + idi + "'";
SqlConnection conapprove = new SqlConnection(strconapprove);
conapprove.Open();
SqlCommand cmdapprove = new SqlCommand(strcmdapprove, conapprove);
SqlDataReader rd;
rd = cmdapprove.ExecuteReader();
if (rd.Read())
{
//picture#1:
string root = Server.MapPath("~");
try
{
byte[] barrImg1 = (byte[])rd.GetValue(rd.GetOrdinal("Picture"));
string strfn1 = root + @"\iimage\" + rd.GetValue(rd.GetOrdinal("Picture")).ToString() + ""+idi+".gif";
FileStream fs1 = new FileStream(strfn1, FileMode.Create, FileAccess.Write);
fs1.Write(barrImg1, 0, barrImg1.Length);
fs1.Flush();
string strpath1 = "~/iimage/" + rd.GetValue(rd.GetOrdinal("Picture")).ToString() +""+idi+ ".gif";
//thumbnail #1
if (fs1.Length != 0)
{
h1.Visible = true;
System.Drawing.Image img1 = System.Drawing.Image.FromFile(Server.MapPath(strpath1));
System.Drawing.Image thumbnailImage1 = img1.GetThumbnailImage(50, 50, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallBack), IntPtr.Zero);
MemoryStream imageStream1 = new MemoryStream();
thumbnailImage1.Save(Server.MapPath("~/image/thumb"+idi+".gif"), System.Drawing.Imaging.ImageFormat.Gif);
byte[] imageContant1 = new byte[imageStream1.Length];
Response.Clear();
h1.ImageUrl = "~/image/thumb"+idi+".gif";
h1.NavigateUrl = "show_picture.aspx?id=" + idi + "&type=pp&name=prayer&profile=aapprove";
fs1.Close();
}
else
{
h1.Visible = false;
}
fs1.Dispose();
}
catch (Exception ex)
{
h1.Visible = false;
}
conapprove.Close();
//problem is that some times it gives the error of GDI.
or outOf memory.
|
|
|
|
|
What's the error ? One possibility is that you never dispose of your resources, and if you open an image you opened before and has not been garbage collected, the file could still be locked.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
This could be the problem, although I don't know what your path and file names are:
string strfn1 = root + @"\iimage\" + rd.GetValue(rd.GetOrdinal("Picture")).ToString() + ""+idi+".gif";
string strfn1 = root + @"\image\" + rd.GetValue(rd.GetOrdinal("Picture")).ToString() + ""+idi+".gif";
You spelt image as iimage. All other places in code you spelt it correctly.
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
|
|
|
|
|
code is not a problem frnd. that's a folder and i think folder's name does't make a problem
|
|
|
|