|
Is google[^] broken where you live ?
|
|
|
|
|
Hello,
I am trying to implement the data list delete feature with a linkbutton.
I have different users who login and can view a message posts. I want to give the ability to delete a message only to the one who posted it. So I am trying to loop through the datalist and check if the logged in user has a posted message show the delete link button otherwise don't show the delete button.
I declared a session for the logged in user Session["UserID"] and I am trying to retrieve the userId from the table like this:
<asp:datalist datakeyfield="ChalkboardID" ondeletecommand="DataList1_DeleteCommand" id="DataList1" repeatlayout="table" runat="server" datasourceid="ChalkDL">
<itemtemplate>
<![CDATA[<%
System.Data.DataView dv = ((System.Data.DataView)(ChalkBTable.Select(DataSourceSelectArguments.Empty)));
noMsgLbl.Text = Session["UserID"].ToString();
foreach (System.Data.DataRowView drv in dv)
{
if (drv.Row["UserID"].Equals(Session["UserID"]))
{ %>]]>
<td style="padding-top: 10px;"><asp:linkbutton visible="true" runat="server" commandname="delete" id="deleteBtn" text="Delete"></asp:linkbutton></td>
}
else
{ %>
<td style="padding-top: 10px;"><asp:linkbutton visible="false" runat="server" commandname="delete" id="LinkButton1" text="Delete"></asp:linkbutton></td>
}
}
%>
</itemtemplate></asp:datalist>
It works correct if there is only one post. Meaning the user who posted the message can delete it and others can't because the delete button is not visible.
But once I add another record it gets messed up. Does anybody see the problem or has another solution for this?
Thank you.
<div class="ForumMod">modified on Sunday, January 06, 2008 6:23:08 PM</div>
|
|
|
|
|
I guess DataList provides a FindControl() method which you can use for finding hyper link and changing visibility instead of mixing markup and server side coding at one place. If you do so, you would be able to step into the code and findo ut which is making problem.
|
|
|
|
|
Thank you for the response.
I can use the step into in the html as well. When you use <% %> it lets create break points, which I did.
The problem is that it loops through the same record and doesn't go further than the first record. I don't know why.
|
|
|
|
|
It seems that the "normal" method for using the FileUpload (or HTML file) control is for the user to choose the file with the upload control, then provide another button (or link or something else) to process that file. So, the user chooses the file, then clicks the other control to update or save the file. I would like to make this a one step process where the file is processed as soon as the user chooses the file. The nicest solution would have been handling a FileUpload control event that indicated when the user had chosen the file and it was uploaded, but there doesn't appear to be any such event.
With help from a CodeProject article, I wrote some javascript to trigger the file upload. The javascript is called in the Click event handler of another button. After the user chooses the file, it continues to the handler to do what I wanted (save to database and update screen). See the code below:
function getFile()<br />
{<br />
var uploadCtrl = document.getElementById("File1");<br />
<br />
uploadCtrl.click();<br />
}<br />
<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
Button1.Attributes.Add("OnClick", "return getFile();");<br />
}<br />
<br />
protected void Button1_Click(object sender, EventArgs e)<br />
{<br />
if (File1.PostedFile != null)<br />
{<br />
}<br />
}
It only gets to Button1_Click after the upload if I remove 'runat="server"' from the HTML file control definition. The problem is that I need 'runat' to get access to PostedFile etc.
Does anyone have any suggestions? If you can fix the above method, I would be very happy. If you have a better way of solving my problem, then I am still happy. If you can educate me on why the above method does what it does, I am always happy to learn.
Thanks,
Dave
|
|
|
|
|
im trying to pass arabic text in my query string.........
but the data appears rabish.......
i rtied to past the result URL and QuerString and worked well.....
so i think the Creat() method ...so plz i need help and this is the method i use....
HttpWebRequest Requset = (HttpWebRequest)HttpWebRequest.Create(URL + "&depositType=" + System.Web.HttpUtility.UrlEncode("Some Arabic Text") + "&transferName=" + System.Web.HttpUtility.UrlEncode("Some Arabic Text"));
Requset.Method = "GET";
HttpWebResponse Response = (System.Net.HttpWebResponse)Requset.GetResponse();
|
|
|
|
|
I want to know how can I save logo(jpge) pic
on jpge pic.
by code...
I want big pic and logo down on the pic.
that will be together.
when I save on web the photo the 2 pic will be 1.
|
|
|
|
|
You can't do anything with the JPEG files directly, you have to load the images into Bitmap objects to work with them.
Use the Graphics.FromImage to create a Graphics object that you can use to draw on the image. Use the DrawImage method to draw the logo onto the image.
If you are uploading the image in a web page, you can load the image directly from the upload stream into a Bitmap object using the Image.FromStream method.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Can someone give code that I can uploading the image in a web page
an add to him logo on the side????
|
|
|
|
|
I explained most of the process. You are supposed to make an effort to put something together, so that there is something substantial to help you with, or at least write a question that is based on the information that I have already given you. If you just repeat the same question over and over, you will get the same replies over and over.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
I try what you write...
how can I save the Graphics object into jpge???
<br />
<br />
Graphics g;<br />
g.DrawImage(System.Drawing.Image.FromFile(""), 0, 0, 10, 10);<br />
g.DrawImage(System.Drawing.Image.FromFile(""), 10, 10, 2, 2);<br />
|
|
|
|
|
The Graphics object itself never contains any drawing data, it's only used to draw on some other object, like the screen or an image.
Something like:
using (Image img1 = Image.FromFile("...")) {
using (Graphics g = Graphics.FromImage(img1)) {
using (img2 = Image.FromFile("...")) {
g.DrawImage(img2, 10, 10, 2, 2);
}
}
img1.Save("...", ...);
}
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
|
Hi and happy new year
I've written a web application program by C# in VStudio 2005 that makes a list of all Windows Services in ther server. I want to start and stop the services. So I've used ServiceController and the mothods Start() and Stop(). But a Win32Exception (Access id Denied) appeared.
for example:
<br />
ServiceController serviceController = new ServiceController("MSSQLServer");<br />
serviceController.Start();<br />
How can I do that? Can anyone help me?
Mehdi
modified on Tuesday, January 08, 2008 3:16:11 AM
|
|
|
|
|
Hi there
I am having a page with GridView in which i have a Edit button. When i click the Edit button i make Response.Redirect to another page. I make modifications there and press OK or Cancel button which redirects me back to the GridView Page.I see the Updates if i have made. and then when i again click Edit to the same record, it shows me the old data that was there before updation. The reason is because it doesnt go to the Page_load method and doesnt get the latest data from the DataBase. But yes if i click the Cancel or OK button it does go to the Page_load method.
So my problem is that when i click Edit button second time for the same record it doesnt go to the page_load method.I know not easy for you to catch the error without seeing my code. If needed please let me know i shall post the required code. Any suggestions or help would be greatly appreciated.
Cheers
Menon
|
|
|
|
|
Have you set a breakpoint and confirmed it's not fired ? It seems more likely that it's loading from the cache.
Christian Graus - Microsoft MVP - C++
"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 Christian
Thank you very much. I was really lost thinking what had gone wrong and that my Page_Load is not getting fired. Yes i forgot to mention i always use breakpoints to debug my code when i have problem.
And i had also came to the conclusion because i had breakpoints and it was not going to the Page_Load i knew it.
Well Your guess was correct it was loading from the Cache. And i got it. I had put the OutputCache in the Page and that was the reason it was loading from the Cache.
Again thank you very much i had spent almost 2 days to figure this out.
If you can tell me this. Is it wrong to use the OutputCache? I was using OutputCache because the page was bit heavy and i thought it would help the page to open if i use OutputCache.
Thank you.
Cheers
Menon
|
|
|
|
|
You need to look into the outputcache documentations. I always used to implement data caching using Cache.Insert and reading from it. In my scenario, this method gave more handle than outputcache. In this all the events fires correctly. Easy way would be creating a cache utility class which manages caching for all the pages.
|
|
|
|
|
Hi Navaneeth,
Thanks for the reply. I will definitely go through the Topic Caching more deeply wherein i can learn to use it more properly.
Thanks
Cheers
Menon
|
|
|
|
|
Hi ,
I need some help about Query String like articles, Examples or E-Books. to know how pass values between pages using for Example value of selected value of DropDownList or other Controls.
Regards
Mr.Wonderful
|
|
|
|
|
|
Your post is pretty vague. Try a google search and many examples are found
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
The concept is incredibly simple. You append values to a URL using the syntax ?key=value&key=value where the ? is the first value, and all other values use &. Then you read the values, which are always strings and use things like intTryParse to convert them as needed.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Does anyone know how to filter image nudity in a online photo application?
|
|
|
|
|
No idea. That is a pretty tall order for a forum query. Only way is probably by manual inspection of each photo in the application.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|